66from typing import Callable , Dict , List , Tuple , Union
77
88
9+ PYTEST_JSON_REPORT = Dict [str , Union [str , List ]]
10+
11+
912import pytest
1013
1114
2225import ai_tutor
2326
2427
28+
2529@pytest .fixture
2630def sample_report_path () -> pathlib .Path :
2731 return test_folder / 'sample_report.json'
2832
2933
3034@pytest .fixture
31- def json_dict (sample_report_path ) -> Dict [ str , Union [ str , List ]] :
35+ def json_dict (sample_report_path ) -> PYTEST_JSON_REPORT :
3236 with sample_report_path .open ('rt' ) as f :
3337 result = json .load (f )
3438 return result
3539
3640
37- def test_collect_longrepr__returns_non_empty (json_dict ):
41+ def test_collect_longrepr__returns_non_empty (json_dict : PYTEST_JSON_REPORT ):
3842 result = ai_tutor .collect_longrepr (json_dict )
3943
4044 assert result
@@ -46,13 +50,13 @@ def div_zero_report_path() -> pathlib.Path:
4650
4751
4852@pytest .fixture
49- def json_dict_div_zero_try_except (div_zero_report_path :pathlib .Path ) -> Dict [ str , Union [ str , List ]] :
53+ def json_dict_div_zero_try_except (div_zero_report_path :pathlib .Path ) -> PYTEST_JSON_REPORT :
5054 with div_zero_report_path .open ('rt' ) as f :
5155 result = json .load (f )
5256 return result
5357
5458
55- def test_collect_longrepr_div_zero_dict__returns_non_empty (json_dict_div_zero_try_except :Dict ):
59+ def test_collect_longrepr_div_zero_dict__returns_non_empty (json_dict_div_zero_try_except :PYTEST_JSON_REPORT ):
5660 result = ai_tutor .collect_longrepr (json_dict_div_zero_try_except )
5761
5862 assert result
@@ -603,5 +607,24 @@ def test_url__specific_model(
603607 assert b_found , f"Could not find { expected_default_gemini_model } in { path_parts } ."
604608
605609
610+ @pytest .fixture
611+ def collect_longrepr_result (json_dict :PYTEST_JSON_REPORT ) -> List [str ]:
612+ return ai_tutor .collect_longrepr (json_dict )
613+
614+
615+ def test__collect_longrepr__is_list (collect_longrepr_result :List [str ]):
616+ assert isinstance (collect_longrepr_result , list ), f"Expected list, got { type (collect_longrepr_result )} ."
617+
618+
619+ def test__collect_longrepr__has_list_items (collect_longrepr_result :List [str ]):
620+ assert collect_longrepr_result , "Expected non-empty list, got empty list."
621+
622+
623+ def test__collect_longrepr__has_list_items_len (collect_longrepr_result :List [str ]):
624+ for s in collect_longrepr_result :
625+ assert isinstance (s , str ), f"Expected string, has { s } which is { type (s )} ."
626+ assert s , "Expected non-empty string, got empty string."
627+
628+
606629if '__main__' == __name__ :
607630 pytest .main ([__file__ ])
0 commit comments