def test_init(self): theapp = app.CromulentApp("tests/data/cromulent/app/jes.conf") self.assertIsNotNone(theapp) self.assertIsNotNone(theapp.config) self.assertIsNone(theapp.db) self.assertEqual(theapp.config['database']['db']['user'], 'cromwell') self.assertEqual(theapp.config['database']['db']['password'], 'words') theapp = app.CromulentApp() self.assertIsNone(theapp.config) self.assertIsNone(theapp.db)
def test_connect(self): theapp = app.CromulentApp("tests/data/cromulent/app/sqlite.conf") self.assertIsNotNone(theapp) self.assertIsNotNone(theapp.config) self.assertIsNone(theapp.db) self.assertEqual(theapp.config['database']['db']['file'], 'tests/data/cromulent/app/test.db') db = theapp.connect() self.assertIsNotNone(db) self.assertIsNotNone(theapp.db)
def cli(ctx): ''' A collection of cromwell helpers. Configuration Set the "CROMULENT_CONFIG" environment variable to the HOCON (JES) config file used by cromwell. Please see README for more details. ''' # to make this script/module behave nicely with unix pipes # http://newbebweb.blogspot.com/2012/02/python-head-ioerror-errno-32-broken.html signal.signal(signal.SIGPIPE, signal.SIG_DFL) ctx.obj = app.CromulentApp(os.environ.get('CROMULENT_CONFIG', None))
def test_runsql(self): theapp = app.CromulentApp("tests/data/cromulent/app/sqlite.conf") db = theapp.connect() sqlrun.run(db, "tests/data/cromulent/sqlrun/select.sql")
def test_connect_fail(self): theapp = app.CromulentApp() with self.assertRaises(Exception) as cm: theapp.connect() self.assertTrue("No configuration found to connect to database!" in cm.exception)
def test_init_fails(self): with self.assertRaises(IOError) as cm: app.CromulentApp("/jes.conf") self.assertTrue("No such file or directory" in cm.exception)