@@ -48,32 +48,39 @@ def test_core_search(run_command, httpserver):
4848 # Search all Retrokit platforms
4949 result = run_command (f"core search retrokit --all --additional-urls={ url } " )
5050 assert result .ok
51- assert 3 == len (result .stdout .strip ().splitlines ())
52- lines = [l .split (maxsplit = 2 ) for l in result .stdout .strip ().splitlines ()]
51+ lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
52+ assert 11 == len (lines )
53+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
54+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
5355 assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
5456 assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
5557
5658 # Search using Retrokit Package Maintainer
5759 result = run_command (f"core search Retrokits-RK002 --all --additional-urls={ url } " )
5860 assert result .ok
59- assert 3 == len (result .stdout .strip ().splitlines ())
60- lines = [l .split (maxsplit = 2 ) for l in result .stdout .strip ().splitlines ()]
61+ lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
62+ assert 11 == len (lines )
63+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
64+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
6165 assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
6266 assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
6367
6468 # Search using the Retrokit Platform name
6569 result = run_command (f"core search rk002 --all --additional-urls={ url } " )
6670 assert result .ok
67- assert 3 == len (result .stdout .strip ().splitlines ())
68- lines = [l .split (maxsplit = 2 ) for l in result .stdout .strip ().splitlines ()]
71+ assert 11 == len (lines )
72+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
73+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
6974 assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
7075 assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
7176
7277 # Search using a board name
7378 result = run_command (f"core search myboard --all --additional-urls={ url } " )
7479 assert result .ok
75- assert 2 == len (result .stdout .strip ().splitlines ())
76- lines = [l .split (maxsplit = 2 ) for l in result .stdout .strip ().splitlines ()]
80+ assert 10 == len (result .stdout .strip ().splitlines ())
81+ lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
82+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
83+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
7784 assert ["Package:x86" , "1.2.3" , "Platform" ] in lines
7885
7986
@@ -95,48 +102,39 @@ def test_core_search_no_args(run_command, httpserver):
95102 result = run_command ("core search" )
96103 assert result .ok
97104 num_platforms = 0
98- found = False
99- for l in result .stdout .splitlines ()[1 :]: # ignore the header on first line
100- if l : # ignore empty lines
101- if l .startswith ("test:x86" ):
102- found = True
103- num_platforms += 1
105+ lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
106+ # 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 :])
104112
105113 # same thing in JSON format, also check the number of platforms found is the same
106114 result = run_command ("core search --format json" )
107115 assert result .ok
108116 platforms = json .loads (result .stdout )
109- found = False
110- platforms = json .loads (result .stdout )
111- for elem in platforms :
112- if elem .get ("Name" ) == "test_core" :
113- found = True
114- break
115- assert found
117+ assert 1 == len ([e for e in platforms if e .get ("Name" ) == "test_core" ])
116118 assert len (platforms ) == num_platforms
117119
118120 # list all with additional urls, check the test core is there
119121 result = run_command (f"core search --additional-urls={ url } " )
120122 assert result .ok
121123 num_platforms = 0
122124 found = False
123- for l in result .stdout .splitlines ()[1 :]: # ignore the header on first line
124- if l : # ignore empty lines
125- if l .startswith ("test:x86" ):
126- found = True
127- num_platforms += 1
128- assert found
125+ lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
126+ # Index update output and the header are printed on the first lines
127+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines [:9 ]
128+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines [:9 ]
129+ assert ["ID" , "Version" , "Name" ] == lines [8 ]
130+ assert ["test:x86" , "2.0.0" , "test_core" ] in lines [9 :]
131+ num_platforms = len (lines [9 :])
129132
130133 # same thing in JSON format, also check the number of platforms found is the same
131134 result = run_command (f"core search --format json --additional-urls={ url } " )
132135 assert result .ok
133- found = False
134136 platforms = json .loads (result .stdout )
135- for elem in platforms :
136- if elem .get ("Name" ) == "test_core" :
137- found = True
138- break
139- assert found
137+ assert 1 == len ([e for e in platforms if e .get ("Name" ) == "test_core" ])
140138 assert len (platforms ) == num_platforms
141139
142140
0 commit comments