Skip to content

Commit f1ca408

Browse files
authored
[skip changelog] Fix core search tests (#1049)
1 parent 4079684 commit f1ca408

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

Diff for: test/test_core.py

+46-14
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,61 @@ def test_core_search(run_command, httpserver):
4949
result = run_command(f"core search retrokit --all --additional-urls={url}")
5050
assert result.ok
5151
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
52-
assert 11 == len(lines)
5352
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
5453
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
5554
assert ["Retrokits-RK002:arm", "1.0.5", "RK002"] in lines
5655
assert ["Retrokits-RK002:arm", "1.0.6", "RK002"] in lines
56+
header_index = lines.index(["ID", "Version", "Name"])
57+
# We use black to format and flake8 to lint .py files but they disagree on certain
58+
# things like this one, thus we ignore this specific flake8 rule and stand by black
59+
# opinion.
60+
# We ignore this specific case because ignoring it globally would probably cause more
61+
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
62+
assert 2 == len(lines[header_index + 1 :]) # noqa: E203
5763

5864
# Search using Retrokit Package Maintainer
5965
result = run_command(f"core search Retrokits-RK002 --all --additional-urls={url}")
6066
assert result.ok
6167
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
62-
assert 11 == len(lines)
6368
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
6469
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
6570
assert ["Retrokits-RK002:arm", "1.0.5", "RK002"] in lines
6671
assert ["Retrokits-RK002:arm", "1.0.6", "RK002"] in lines
72+
# We use black to format and flake8 to lint .py files but they disagree on certain
73+
# things like this one, thus we ignore this specific flake8 rule and stand by black
74+
# opinion.
75+
# We ignore this specific case because ignoring it globally would probably cause more
76+
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
77+
assert 2 == len(lines[header_index + 1 :]) # noqa: E203
6778

6879
# Search using the Retrokit Platform name
6980
result = run_command(f"core search rk002 --all --additional-urls={url}")
7081
assert result.ok
71-
assert 11 == len(lines)
82+
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
7283
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
7384
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
7485
assert ["Retrokits-RK002:arm", "1.0.5", "RK002"] in lines
7586
assert ["Retrokits-RK002:arm", "1.0.6", "RK002"] in lines
87+
# We use black to format and flake8 to lint .py files but they disagree on certain
88+
# things like this one, thus we ignore this specific flake8 rule and stand by black
89+
# opinion.
90+
# We ignore this specific case because ignoring it globally would probably cause more
91+
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
92+
assert 2 == len(lines[header_index + 1 :]) # noqa: E203
7693

7794
# Search using a board name
7895
result = run_command(f"core search myboard --all --additional-urls={url}")
7996
assert result.ok
80-
assert 10 == len(result.stdout.strip().splitlines())
8197
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
8298
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
8399
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
84100
assert ["Package:x86", "1.2.3", "Platform"] in lines
101+
# We use black to format and flake8 to lint .py files but they disagree on certain
102+
# things like this one, thus we ignore this specific flake8 rule and stand by black
103+
# opinion.
104+
# We ignore this specific case because ignoring it globally would probably cause more
105+
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
106+
assert 1 == len(lines[header_index + 1 :]) # noqa: E203
85107

86108

87109
def test_core_search_no_args(run_command, httpserver):
@@ -104,11 +126,16 @@ def test_core_search_no_args(run_command, httpserver):
104126
num_platforms = 0
105127
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
106128
# Index update output and the header are printed on the first lines
107-
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines[:6]
108-
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines[:6]
109-
assert ["ID", "Version", "Name"] == lines[5]
110-
assert ["test:x86", "2.0.0", "test_core"] in lines[6:]
111-
num_platforms = len(lines[6:])
129+
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
130+
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
131+
assert ["test:x86", "2.0.0", "test_core"] in lines
132+
header_index = lines.index(["ID", "Version", "Name"])
133+
# We use black to format and flake8 to lint .py files but they disagree on certain
134+
# things like this one, thus we ignore this specific flake8 rule and stand by black
135+
# opinion.
136+
# We ignore this specific case because ignoring it globally would probably cause more
137+
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
138+
num_platforms = len(lines[header_index + 1 :]) # noqa: E203
112139

113140
# same thing in JSON format, also check the number of platforms found is the same
114141
result = run_command("core search --format json")
@@ -123,11 +150,16 @@ def test_core_search_no_args(run_command, httpserver):
123150
num_platforms = 0
124151
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
125152
# Index update output and the header are printed on the first lines
126-
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines[:9]
127-
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines[:9]
128-
assert ["ID", "Version", "Name"] == lines[8]
129-
assert ["test:x86", "2.0.0", "test_core"] in lines[9:]
130-
num_platforms = len(lines[9:])
153+
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
154+
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
155+
assert ["test:x86", "2.0.0", "test_core"] in lines
156+
header_index = lines.index(["ID", "Version", "Name"])
157+
# We use black to format and flake8 to lint .py files but they disagree on certain
158+
# things like this one, thus we ignore this specific flake8 rule and stand by black
159+
# opinion.
160+
# We ignore this specific case because ignoring it globally would probably cause more
161+
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
162+
num_platforms = len(lines[header_index + 1 :]) # noqa: E203
131163

132164
# same thing in JSON format, also check the number of platforms found is the same
133165
result = run_command(f"core search --format json --additional-urls={url}")

0 commit comments

Comments
 (0)