示例#1
0
    def test_officer_allegation_dataframe_is_filled_when_load_officer_into_db(self):
        testLoader = Loader()
        df = pd.DataFrame([{
            "cr_id": '1008899',
            "number_of_officer_rows": 1,
            "beat_id": 433,
            "officer_race": ['White'],
            "officer_gender": ['M'],
            "officer_age": ['40-49'],
            "officer_years_on_force": ['0-4']
        }])
        for panda_row in df.itertuples():
            testLoader.load_officers_into_db(1, "1008899", panda_row)

        actual_data = testLoader.new_officer_allegation_data
        expected_data = pd.DataFrame([
            {
                "allegation_id": '1008899',
                "recc_finding": "NA",
                "recc_outcome": "NA",
                "final_finding": "NA",
                "final_outcome": "NA",
                "final_outcome_class": "NA",
            }
        ])
        assert_frame_equal(actual_data, expected_data, check_like=True)
示例#2
0
    def test_unknown_officer_dataframe_is_filled_when_load_officer_into_db(self):
        testLoader = Loader()
        df = pd.DataFrame([{
            "cr_id": '1008899',
            "number_of_officer_rows": 1,
            "beat_id": 433,
            "officer_race": ['White'],
            "officer_gender": ['M'],
            "officer_age": ['40-49'],
            "officer_years_on_force": ['0-4']
        }])
        for panda_row in df.itertuples():
            testLoader.load_officers_into_db(1, "1008899", panda_row)

        actual_data = testLoader.new_officer_unknown_data
        expected_data = pd.DataFrame([
            {
                "data_officerallegation_id": 1,
                "age": '40-49',
                "race": 'White',
                "gender": 'M',
                "years_on_force": '0-4'
            }
        ])
        assert_frame_equal(actual_data, expected_data, check_like=True, check_dtype=False)