Skip to content

Commit 3e07fbe

Browse files
committed
[skip changelog] Fix core search tests
1 parent 4079684 commit 3e07fbe

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

Diff for: .flake8

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[flake8]
44
max-line-length = 120
55
ignore =
6+
E203,
67
E741,
78
# W503 and W504 are mutually exclusive, so one or the other must be ignored.
89
# PEP 8 recommends line break before, so we keep W504.

Diff for: test/test_core.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,41 @@ 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+
assert 2 == len(lines[header_index + 1 :])
5758

5859
# Search using Retrokit Package Maintainer
5960
result = run_command(f"core search Retrokits-RK002 --all --additional-urls={url}")
6061
assert result.ok
6162
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
62-
assert 11 == len(lines)
6363
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
6464
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
6565
assert ["Retrokits-RK002:arm", "1.0.5", "RK002"] in lines
6666
assert ["Retrokits-RK002:arm", "1.0.6", "RK002"] in lines
67+
assert 2 == len(lines[header_index + 1 :])
6768

6869
# Search using the Retrokit Platform name
6970
result = run_command(f"core search rk002 --all --additional-urls={url}")
7071
assert result.ok
71-
assert 11 == len(lines)
72+
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
7273
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
7374
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
7475
assert ["Retrokits-RK002:arm", "1.0.5", "RK002"] in lines
7576
assert ["Retrokits-RK002:arm", "1.0.6", "RK002"] in lines
77+
assert 2 == len(lines[header_index + 1 :])
7678

7779
# Search using a board name
7880
result = run_command(f"core search myboard --all --additional-urls={url}")
7981
assert result.ok
80-
assert 10 == len(result.stdout.strip().splitlines())
8182
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
8283
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
8384
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
8485
assert ["Package:x86", "1.2.3", "Platform"] in lines
86+
assert 1 == len(lines[header_index + 1 :])
8587

8688

8789
def test_core_search_no_args(run_command, httpserver):
@@ -104,11 +106,11 @@ def test_core_search_no_args(run_command, httpserver):
104106
num_platforms = 0
105107
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
106108
# 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:])
109+
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
110+
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
111+
assert ["test:x86", "2.0.0", "test_core"] in lines
112+
header_index = lines.index(["ID", "Version", "Name"])
113+
num_platforms = len(lines[header_index + 1 :])
112114

113115
# same thing in JSON format, also check the number of platforms found is the same
114116
result = run_command("core search --format json")
@@ -123,11 +125,11 @@ def test_core_search_no_args(run_command, httpserver):
123125
num_platforms = 0
124126
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
125127
# 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:])
128+
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
129+
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
130+
assert ["test:x86", "2.0.0", "test_core"] in lines
131+
header_index = lines.index(["ID", "Version", "Name"])
132+
num_platforms = len(lines[header_index + 1 :])
131133

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

0 commit comments

Comments
 (0)