def test_syncdb(self): """ Assert that the syncdb mechanism is functioning """ def count_clients(): result = db.session.execute("SELECT COUNT(*) FROM client;") return result.fetchone()[0] def count_credentials(): result = db.session.execute("SELECT COUNT(*) FROM credential;") return result.fetchone()[0] # Ensure that the client table hasn't been created self.assertRaises(ProgrammingError, count_clients) db.session.rollback() # Ensure that the credential table hasn't been created self.assertRaises(ProgrammingError, count_credentials) db.session.rollback() syncdb() # Ensure that the client table has been created self.assertEqual(0, count_clients(), "Client table was not created") # Ensure that the credential table has been created self.assertEqual(0, count_credentials(), "Credential table was not created")
def setUp(self): syncdb() # Uses the schema to create the database
def setUp(self): syncdb() # Uses the schema to create the database client = Client("Test Client", self.APIKEY, self.SECRET) db.session.add(client) db.session.commit()