@@ -210,6 +210,92 @@ def test_kcidev_results_summary_history_import():
210210 assert "/" in result # Should contain separators
211211
212212
213+ def test_kcidev_results_hardware_list ():
214+ """Test that hardware list command works and returns expected output format"""
215+ command = [
216+ "poetry" ,
217+ "run" ,
218+ "kci-dev" ,
219+ "results" ,
220+ "hardware" ,
221+ "list" ,
222+ "--origin" ,
223+ "maestro" ,
224+ ]
225+ result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
226+
227+ print ("returncode: " + str (result .returncode ))
228+ print ("#### stdout ####" )
229+ print (result .stdout )
230+ print ("#### stderr ####" )
231+ print (result .stderr )
232+
233+ # Test should succeed
234+ assert result .returncode == 0
235+
236+ # Should contain hardware entries with expected format
237+ output_lines = result .stdout .strip ().split ("\n " )
238+
239+ # Should have at least some hardware entries
240+ assert len (output_lines ) > 0
241+
242+ # Check format: lines should contain "- name:" and "compatibles:"
243+ name_lines = [line for line in output_lines if line .strip ().startswith ("- name:" )]
244+ compatible_lines = [
245+ line for line in output_lines if line .strip ().startswith ("compatibles:" )
246+ ]
247+
248+ # Should have matching number of name and compatible lines
249+ assert len (name_lines ) > 0
250+ assert len (compatible_lines ) > 0
251+ assert len (name_lines ) == len (compatible_lines )
252+
253+
254+ def test_kcidev_results_hardware_list_json ():
255+ """Test that hardware list command works with JSON output"""
256+ command = [
257+ "poetry" ,
258+ "run" ,
259+ "kci-dev" ,
260+ "results" ,
261+ "hardware" ,
262+ "list" ,
263+ "--origin" ,
264+ "maestro" ,
265+ "--json" ,
266+ ]
267+ result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
268+
269+ print ("returncode: " + str (result .returncode ))
270+ print ("#### stdout ####" )
271+ print (result .stdout [:500 ] + "..." if len (result .stdout ) > 500 else result .stdout )
272+ print ("#### stderr ####" )
273+ print (result .stderr )
274+
275+ # Test should succeed
276+ assert result .returncode == 0
277+
278+ # Should be valid JSON
279+ import json
280+
281+ try :
282+ data = json .loads (result .stdout )
283+ assert isinstance (data , list )
284+
285+ # Should have at least some hardware entries
286+ assert len (data ) > 0
287+
288+ # Each entry should have 'name' and 'compatibles' fields
289+ for entry in data [:5 ]: # Check first 5 entries
290+ assert "name" in entry
291+ assert "compatibles" in entry
292+ assert isinstance (entry ["name" ], str )
293+ assert isinstance (entry ["compatibles" ], str )
294+
295+ except json .JSONDecodeError :
296+ pytest .fail ("Output is not valid JSON" )
297+
298+
213299def test_clean ():
214300 # clean enviroment
215301 shutil .rmtree ("my-new-repo/" )
0 commit comments