From 8408ef12a9ac542f12ac2989e5688a430ab62d88 Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Wed, 28 Oct 2020 15:56:14 +0100 Subject: [PATCH] [skip changelog] Fix core search tests --- test/test_core.py | 60 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/test/test_core.py b/test/test_core.py index 7fec0943f1c..ddf42da08e3 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -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 def test_core_search_no_args(run_command, httpserver): @@ -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") @@ -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}")