def generate_test_data(): def get_date_days_ago(days): return datetime.datetime.now() - datetime.timedelta(days=days) [ FireIncidentFactory( incident_address="123 TEST LN", alarm_datetime=get_date_days_ago(5), actual_nfirs_incident_type_description="Broken Nose") for i in range(0, 5) ] [ FireIncidentFactory( incident_address="123 TEST LN", alarm_datetime=get_date_days_ago(20), actual_nfirs_incident_type_description="Stubbed Toe") for i in range(0, 8) ] [ FireIncidentFactory( incident_address="123 TEST LN", alarm_datetime=get_date_days_ago(40), actual_nfirs_incident_type_description="Myocardial Infarction") for i in range(0, 7) ] [ FireIncidentFactory( incident_address="123 TEST LN", alarm_datetime=get_date_days_ago(200), actual_nfirs_incident_type_description="Lung Fell Off") for i in range(0, 10) ] [ PoliceIncidentFactory( incident_address="123 TEST LN", call_datetime=get_date_days_ago(5), final_cad_call_type_description="Stepped on a Crack") for i in range(0, 3) ] [ PoliceIncidentFactory(incident_address="123 TEST LN", call_datetime=get_date_days_ago(20), final_cad_call_type_description="Whipped It") for i in range(0, 8) ] [ PoliceIncidentFactory(incident_address="123 TEST LN", call_datetime=get_date_days_ago(40), final_cad_call_type_description="Safety Dance") for i in range(0, 9) ] [ PoliceIncidentFactory( incident_address="123 TEST LN", call_datetime=get_date_days_ago(200), final_cad_call_type_description="Runnin' With The Devil") for i in range(0, 6) ]
def generate_fire_data(): num_records = AVG_RECORDS_PER_ADDRESS * len(ADDRESSES) incidents = [ FireIncidentFactory( street_number=factory.fuzzy.FuzzyChoice(STREET_NUMBERS), street_name=factory.fuzzy.FuzzyChoice(STREET_NAMES), street_type=factory.LazyAttribute(generate_street_type), incident_address=factory.LazyAttribute(generate_address), alarm_datetime=factory.fuzzy.FuzzyDateTime(START_DATE), actual_nfirs_incident_type_description=factory.fuzzy.FuzzyChoice( FIRE_TYPES)) for i in range(num_records) ]
def test_fetch_incident_at_address_works_if_lowercase_supplied(self): [ FireIncidentFactory(standardized_address="123 MAIN ST") for i in range(0, 5) ] [ PoliceIncidentFactory(standardized_address="123 MAIN ST") for i in range(0, 3) ] [ BusinessLicenseFactory(business_address="123 MAIN ST") for i in range(0, 1) ] db.session.flush() incidents = fetch_incidents_at_address("123 main st") assert len(incidents['fire']) == 5 assert len(incidents['police']) == 3 assert len(incidents['businesses']) == 1
def test_fetch_incident_at_address_returns_correct_number_of_items(self): [ FireIncidentFactory(standardized_address="123 MAIN ST") for i in range(5) ] [ PoliceIncidentFactory(standardized_address="123 MAIN ST") for i in range(3) ] [ BusinessLicenseFactory(business_address="123 MAIN ST") for i in range(1) ] db.session.flush() incidents = fetch_incidents_at_address("123 MAIN ST") assert len(incidents['fire']) == 5 assert len(incidents['police']) == 3 assert len(incidents['businesses']) == 1