@@ -48,32 +48,39 @@ def test_core_search(run_command, httpserver):
48
48
# Search all Retrokit platforms
49
49
result = run_command (f"core search retrokit --all --additional-urls={ url } " )
50
50
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
53
55
assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
54
56
assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
55
57
56
58
# Search using Retrokit Package Maintainer
57
59
result = run_command (f"core search Retrokits-RK002 --all --additional-urls={ url } " )
58
60
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
61
65
assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
62
66
assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
63
67
64
68
# Search using the Retrokit Platform name
65
69
result = run_command (f"core search rk002 --all --additional-urls={ url } " )
66
70
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
69
74
assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
70
75
assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
71
76
72
77
# Search using a board name
73
78
result = run_command (f"core search myboard --all --additional-urls={ url } " )
74
79
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
77
84
assert ["Package:x86" , "1.2.3" , "Platform" ] in lines
78
85
79
86
@@ -95,48 +102,39 @@ def test_core_search_no_args(run_command, httpserver):
95
102
result = run_command ("core search" )
96
103
assert result .ok
97
104
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 :])
104
112
105
113
# same thing in JSON format, also check the number of platforms found is the same
106
114
result = run_command ("core search --format json" )
107
115
assert result .ok
108
116
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" ])
116
118
assert len (platforms ) == num_platforms
117
119
118
120
# list all with additional urls, check the test core is there
119
121
result = run_command (f"core search --additional-urls={ url } " )
120
122
assert result .ok
121
123
num_platforms = 0
122
124
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 :])
129
132
130
133
# same thing in JSON format, also check the number of platforms found is the same
131
134
result = run_command (f"core search --format json --additional-urls={ url } " )
132
135
assert result .ok
133
- found = False
134
136
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" ])
140
138
assert len (platforms ) == num_platforms
141
139
142
140
0 commit comments