def add_concepts(self): """Only tests needing concepts should load - VERY SLOW The concept load includes pulling large JSON files, parsing and numerous db lookups. Only load in test if needed. """ with SessionScope(db): add_static_concepts(only_quick=False) db.session.commit()
def seed(keep_unmentioned=False): """Actual seed function NB this is defined separately so it can also be called internally, i.e. from sync """ # Request context necessary for generating data from own HTTP APIs with app.test_request_context(): add_static_concepts() add_static_interventions() add_static_organization() add_static_relationships() add_static_roles() db.session.commit() # import site export file if found SitePersistence(target_dir=None).import_(keep_unmentioned=keep_unmentioned)
def seed(exclude_interventions=False, keep_unmentioned=False): """Seed database with required data""" # Request context necessary for generating data from own HTTP APIs with app.test_request_context(): add_static_concepts() add_static_interventions() add_static_organization() add_static_relationships() add_static_roles() db_maintenance() db.session.commit() # Always update interventions on development systems if app.config["SYSTEM_TYPE"].lower() == 'development': exclude_interventions = False # import site export file if found SitePersistence().import_(exclude_interventions, keep_unmentioned)
def setUp(self): """Reset all tables before testing.""" db.drop_all() # clean up from previous tests db.create_all() with SessionScope(db): # concepts take forever, only load the quick ones. # add directly (via self.add_concepts()) if test needs them add_static_concepts(only_quick=True) add_static_interventions() add_static_organization() add_static_relationships() add_static_roles() db.session.commit() self.init_data() # bootstrapping mysteries continue, config variables set during # tests don't die; removed unwanted config items if present for item in ( 'REQUIRED_CORE_DATA', 'LOCALIZED_AFFILIATE_ORG', 'ACCEPT_TERMS_ON_NEXT_ORG'): if item in self.client.application.config: del self.client.application.config[item]
def setUp(self): """Reset all tables before testing.""" db.drop_all() # clean up from previous tests db.create_all() with SessionScope(db): # concepts take forever, only load the quick ones. # add directly (via self.add_concepts()) if test needs them add_static_concepts(only_quick=True) add_static_interventions() add_static_organization() add_static_relationships() add_static_roles() db.session.commit() self.init_data() self.client = self.__app.test_client() # removed unwanted config items if present for item in ('REQUIRED_CORE_DATA', 'LOCALIZED_AFFILIATE_ORG'): if item in self.client.application.config: del self.client.application.config[item] # reload coredata config configure_coredata(self.client.application)