def check_response_record_matches_mock_crawler_search(record_dict, mock_record): # response data is now sorted by date just before return in search.py # so test cases should be sorted with same method when testing against search.py sorted_mock_record = RecordCreator.sort_record_by_case_date(mock_record) assert record_dict["total_balance_due"] == mock_record.total_balance_due case_numbers = [case["case_number"] for case in record_dict["cases"]] mocked_case_numbers = [case.summary.case_number for case in sorted_mock_record.cases]
def test_sort_if_all_dates_are_same(): case1 = CaseFactory.create(case_number="1") case2 = CaseFactory.create(case_number="2") case3 = CaseFactory.create(case_number="3") record = Record(tuple([case1, case2, case3])) assert record.cases[0].summary.case_number == "1" assert record.cases[1].summary.case_number == "2" assert record.cases[2].summary.case_number == "3" sorted_record = RecordCreator.sort_record_by_case_date(record) assert sorted_record.cases[0].summary.case_number == "1" assert sorted_record.cases[1].summary.case_number == "2" assert sorted_record.cases[2].summary.case_number == "3"
def test_sort_by_case_date(): case1 = CaseFactory.create(case_number="1", date_location=["1/1/2018", "Multnomah"]) case2 = CaseFactory.create(case_number="2", date_location=["1/1/2019", "Multnomah"]) case3 = CaseFactory.create(case_number="3", date_location=["1/1/2020", "Multnomah"]) record = Record(tuple([case1, case2, case3])) assert record.cases[0].summary.case_number == "1" assert record.cases[1].summary.case_number == "2" assert record.cases[2].summary.case_number == "3" sorted_record = RecordCreator.sort_record_by_case_date(record) assert sorted_record.cases[0].summary.case_number == "3" assert sorted_record.cases[1].summary.case_number == "2" assert sorted_record.cases[2].summary.case_number == "1"