def test_load_cases(self): import_service = import_service_module.ImportService() dycast_model = dycast_parameters.DycastParameters() dycast_model.srid_of_cases = '3857' dycast_model.files_to_import = test_helper_functions.get_test_cases_import_files_latlong( ) import_service.load_case_files(dycast_model)
def import_cases(self): import_service = import_service_module.ImportService() if self.files_to_import: import_service.load_case_files(self) else: logging.info("Loading files from import path: %s", self.dead_birds_dir) raise NotImplementedError logging.info("Done loading cases")
def test_load_case_data_error(self): session = database_service.get_sqlalchemy_session() import_service = import_service_module.ImportService() dycast_model = dycast_parameters.DycastParameters() dycast_model.srid_of_cases = 3857 location_type = enums.Location_type.LAT_LONG line_incorrect_date = "9998\t30/09/16\t1832445.278\t2118527.399" with self.assertRaises(DataError): import_service.load_case(session, dycast_model, line_incorrect_date, location_type)
def test_generate_risk(self): dycast_parameters = test_helper_functions.get_dycast_parameters( large_dataset=False) risk_service = risk_service_module.RiskService(dycast_parameters) import_service = import_service_module.ImportService() import_service.load_case_files(dycast_parameters) risk_service.generate_risk() risk_count = test_helper_functions.get_count_from_table("risk") self.assertGreaterEqual(risk_count, 6)
def insert_test_cases(): import_service = import_service_module.ImportService() dycast_model = dycast_parameters.DycastParameters() dycast_model.srid_of_cases = '3857' dycast_model.files_to_import = get_test_cases_import_files_latlong() session = database_service.get_sqlalchemy_session() case_query = session.query(Case) case_count = database_service.get_count_for_query(case_query) if case_count == 0: import_service.load_case_files(dycast_model)
def test_load_case_correct(self): session = database_service.get_sqlalchemy_session() import_service = import_service_module.ImportService() dycast_model = dycast_parameters.DycastParameters() dycast_model.srid_of_cases = 3857 line_correct = "99999\t03/09/16\t1832445.278\t2118527.399" location_type = enums.Location_type.LAT_LONG import_service.load_case(session, dycast_model, line_correct, location_type) session.commit() query = session.query(Case).filter(Case.id == '99999') count = database_service.get_count_for_query(query) self.assertEqual(count, 1) session.delete(query.first()) session.commit()