Skip to content

Commit 8885795

Browse files
committed
Format with black
1 parent b1db688 commit 8885795

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed

tests/test_fetch.py

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,14 @@ def subject():
3434
class TestFetch:
3535
def test_getattribute(self, schema_any, subject):
3636
"""Testing Fetch.__call__ with attributes"""
37-
list1 = sorted(
38-
subject.proj().fetch(as_dict=True), key=itemgetter("subject_id")
39-
)
37+
list1 = sorted(subject.proj().fetch(as_dict=True), key=itemgetter("subject_id"))
4038
list2 = sorted(subject.fetch(dj.key), key=itemgetter("subject_id"))
4139
for l1, l2 in zip(list1, list2):
4240
assert l1 == l2, "Primary key is not returned correctly"
4341

4442
tmp = subject.fetch(order_by="subject_id")
4543

46-
subject_notes, key, real_id = subject.fetch(
47-
"subject_notes", dj.key, "real_id"
48-
)
44+
subject_notes, key, real_id = subject.fetch("subject_notes", dj.key, "real_id")
4945

5046
np.testing.assert_array_equal(
5147
sorted(subject_notes), sorted(tmp["subject_notes"])
@@ -58,9 +54,10 @@ def test_getattribute(self, schema_any, subject):
5854
def test_getattribute_for_fetch1(self, schema_any, subject):
5955
"""Testing Fetch1.__call__ with attributes"""
6056
assert (subject & "subject_id=10").fetch1("subject_id") == 10
61-
assert (
62-
(subject & "subject_id=10").fetch1("subject_id", "species") ==
63-
(10, "monkey"))
57+
assert (subject & "subject_id=10").fetch1("subject_id", "species") == (
58+
10,
59+
"monkey",
60+
)
6461

6562
def test_order_by(self, schema_any, lang, languages):
6663
"""Tests order_by sorting order"""
@@ -69,15 +66,19 @@ def test_order_by(self, schema_any, lang, languages):
6966
languages.sort(key=itemgetter(1), reverse=ord_lang == "DESC")
7067
languages.sort(key=itemgetter(0), reverse=ord_name == "DESC")
7168
for c, l in zip(cur, languages):
72-
assert np.all(cc == ll for cc, ll in zip(c, l)), "Sorting order is different"
69+
assert np.all(
70+
cc == ll for cc, ll in zip(c, l)
71+
), "Sorting order is different"
7372

7473
def test_order_by_default(self, schema_any, lang, languages):
7574
"""Tests order_by sorting order with defaults"""
7675
cur = lang.fetch(order_by=("language", "name DESC"))
7776
languages.sort(key=itemgetter(0), reverse=True)
7877
languages.sort(key=itemgetter(1), reverse=False)
7978
for c, l in zip(cur, languages):
80-
assert np.all([cc == ll for cc, ll in zip(c, l)]), "Sorting order is different"
79+
assert np.all(
80+
[cc == ll for cc, ll in zip(c, l)]
81+
), "Sorting order is different"
8182

8283
def test_limit(self, schema_any, lang):
8384
"""Test the limit kwarg"""
@@ -92,7 +93,9 @@ def test_order_by_limit(self, schema_any, lang, languages):
9293
languages.sort(key=itemgetter(1), reverse=False)
9394
assert len(cur) == 4, "Length is not correct"
9495
for c, l in list(zip(cur, languages))[:4]:
95-
assert np.all([cc == ll for cc, ll in zip(c, l)]), "Sorting order is different"
96+
assert np.all(
97+
[cc == ll for cc, ll in zip(c, l)]
98+
), "Sorting order is different"
9699

97100
def test_head_tail(self, schema_any):
98101
query = schema.User * schema.Language
@@ -118,7 +121,9 @@ def test_limit_offset(self, schema_any, lang, languages):
118121
languages.sort(key=itemgetter(1), reverse=False)
119122
assert len(cur) == 4, "Length is not correct"
120123
for c, l in list(zip(cur, languages[2:6])):
121-
assert np.all([cc == ll for cc, ll in zip(c, l)]), "Sorting order is different"
124+
assert np.all(
125+
[cc == ll for cc, ll in zip(c, l)]
126+
), "Sorting order is different"
122127

123128
def test_iter(self, schema_any, lang, languages):
124129
"""Test iterator"""
@@ -130,7 +135,9 @@ def test_iter(self, schema_any, lang, languages):
130135
# now as dict
131136
cur = lang.fetch(as_dict=True, order_by=("language", "name DESC"))
132137
for row, (tname, tlang) in list(zip(cur, languages)):
133-
assert row["name"] == tname and row["language"] == tlang, "Values are not the same"
138+
assert (
139+
row["name"] == tname and row["language"] == tlang
140+
), "Values are not the same"
134141

135142
def test_keys(self, schema_any, lang, languages):
136143
"""test key fetch"""
@@ -154,14 +161,18 @@ def test_attributes_as_dict(self, schema_any, subject):
154161
assert set(result[0]) == set(attrs)
155162

156163
def test_fetch1_step1(self, schema_any, lang, languages):
157-
assert lang.contents == languages == [
158-
("Fabian", "English"),
159-
("Edgar", "English"),
160-
("Dimitri", "English"),
161-
("Dimitri", "Ukrainian"),
162-
("Fabian", "German"),
163-
("Edgar", "Japanese"),
164-
], "Unexpected contents in Language table"
164+
assert (
165+
lang.contents
166+
== languages
167+
== [
168+
("Fabian", "English"),
169+
("Edgar", "English"),
170+
("Dimitri", "English"),
171+
("Dimitri", "Ukrainian"),
172+
("Fabian", "German"),
173+
("Edgar", "Japanese"),
174+
]
175+
), "Unexpected contents in Language table"
165176
key = {"name": "Edgar", "language": "Japanese"}
166177
true = languages[-1]
167178
dat = (lang & key).fetch1()
@@ -199,8 +210,12 @@ def test_offset(self, schema_any, lang, languages):
199210
languages.sort(key=itemgetter(1), reverse=False)
200211
assert len(cur) == 4, "Length is not correct"
201212
for c, l in list(zip(cur, languages[1:]))[:4]:
202-
assert np.all([cc == ll for cc, ll in zip(c, l)]), "Sorting order is different"
203-
assert len(schema.DecimalPrimaryKey().fetch()), "Table DecimalPrimaryKey is empty"
213+
assert np.all(
214+
[cc == ll for cc, ll in zip(c, l)]
215+
), "Sorting order is different"
216+
assert len(
217+
schema.DecimalPrimaryKey().fetch()
218+
), "Table DecimalPrimaryKey is empty"
204219

205220
def test_limit_warning(self, schema_any, lang):
206221
"""Tests whether warning is raised if offset is used without limit."""

0 commit comments

Comments
 (0)