Skip to content

[skip changelog] Fix core search tests #1049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,39 +49,61 @@ def test_core_search(run_command, httpserver):
result = run_command(f"core search retrokit --all --additional-urls={url}")
assert result.ok
lines = [l.strip().split() for l in result.stdout.strip().splitlines()]
assert 11 == len(lines)
assert ["Updating", "index:", "package_index.json", "downloaded"] in lines
assert ["Updating", "index:", "package_index.json.sig", "downloaded"] in lines
assert ["Retrokits-RK002:arm", "1.0.5", "RK002"] in lines
assert ["Retrokits-RK002:arm", "1.0.6", "RK002"] in lines
header_index = lines.index(["ID", "Version", "Name"])
# We use black to format and flake8 to lint .py files but they disagree on certain
# things like this one, thus we ignore this specific flake8 rule and stand by black
# opinion.
# We ignore this specific case because ignoring it globally would probably cause more
# issue. For more info about the rule see: https://www.flake8rules.com/rules/E203.html
assert 2 == len(lines[header_index + 1 :]) # noqa: E203

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

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document what # noqa: E203 does. At least in the commit message. Thanks!



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

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

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