def test_load_fixture(self): create_table(Base) fixtures = load_fixture_files(self.path, ['accounts.yaml']) load_fixtures(session, fixtures) accounts = session.query(Account).all() self.assertEqual(len(accounts), 2) drop_table(Base, session)
def test_load_json_fixtures(self): create_table(Base) fixtures = load_fixture_files( self.path, ['accounts.json', 'pictures.json'], ) load_fixtures(session, fixtures) accounts = session.query(Account).all() self.assertEqual(len(accounts), 2) pictures = session.query(Picture).all() self.assertEqual(len(pictures), 4) drop_table(Base, session)
def test_load_fixture_by_wrong_order(self): # Picture has relationship to Account. # Model instances are added by `session.add_all()`. # So, it does not fail. create_table(Base) fixtures = load_fixture_files( self.path, ['pictures.yaml', 'accounts.yaml'], ) load_fixtures(session, fixtures) accounts = session.query(Account).all() self.assertEqual(len(accounts), 2) pictures = session.query(Picture).all() self.assertEqual(len(pictures), 4) drop_table(Base, session)
def test_drop_table(self): create_table(Base) drop_table(Base, session) with self.assertRaises(OperationalError): session.query(Account).all()
def test_create_table(self): create_table(Base) accounts = session.query(Account).all() self.assertEqual(len(accounts), 0)