def test_factories(use_db): location = LocationFactory(id=4) CaseDataFactory(location=location, confirmed=100, recovered=50, fatal=0) record = CaseData.query.first() assert record assert record.confirmed == 100 assert record.recovered == 50 assert record.fatal == 0 assert record.location_id == 4
def simple_db(db): """a set of ca, location, mh, and vendor for tests.""" mini_db = {} # create vendor v = VendorFactory() mini_db['vendor'] = v db.session.commit() # need the vendor.id to create ca # create a bunch of capture agents mini_db['ca'] = [] for i in range(5): mini_db['ca'].append(CaFactory(vendor_id=mini_db['vendor'].id)) # create a bunch of rooms mini_db['room'] = [] for i in range(5): mini_db['room'].append(LocationFactory()) # create a bunch of clusters mini_db['cluster'] = [] for i in range(3): mini_db['cluster'].append(MhClusterFactory()) db.session.commit() role_p1 = Role.create(location=mini_db['room'][0], ca=mini_db['ca'][0], cluster=mini_db['cluster'][0], name='experimental') role_p2 = Role.create(location=mini_db['room'][0], ca=mini_db['ca'][1], cluster=mini_db['cluster'][0], name='experimental') role_p3 = Role.create(location=mini_db['room'][0], ca=mini_db['ca'][2], cluster=mini_db['cluster'][0], name='primary') db.session.commit() return mini_db
def locations(self): return [ LocationFactory(id=1, minzdrav_name="Алматы"), LocationFactory(id=2, minzdrav_name="Астана"), LocationFactory(id=3, minzdrav_name="Шымкент"), ]