def test_the_data_is_persistent_orm_model(self): configure_orm({ "db_config": db_config, "apps": ["tests.testapp.appo", "tests.testapp2"] }) # every model declared has the same db_manager self.assertTrue(orm_app.db_manager is Book.objects.db_manager)
def test_get_model_not_correct_format(self): orm = configure_orm({'db_config': db_config, 'apps': ['tests.testapp', 'tests.testapp2']}) with self.assertRaises(ModelError) as exc: orm.get_model('here.there.what') self.assertIn('The string declared should be in format ', exc.exception.args[0])
def test_ormconfigure_no_models(self): orm = configure_orm({'db_config': db_config, 'apps': None}) with self.assertRaises(AppError) as exc: orm.get_model('here.there.what') self.assertTrue('There are no apps declared in the orm' == exc.exception.args[0])
def test_ormconfigure_no_models(self): orm = configure_orm({"db_config": db_config, "apps": None}) with self.assertRaises(AppError) as exc: orm.get_model("here.what") self.assertTrue( "There are no apps declared in the orm" == exc.exception.args[0])
def test_get_model_not_correct_format(self): orm = configure_orm({ "db_config": db_config, "apps": ["tests.testapp", "tests.testapp2"] }) with self.assertRaises(ModelError) as exc: orm.get_model("here.there.what") self.assertIn("The string declared should be in format ", exc.exception.args[0])
def configure_orm(self): config_filename = os.path.join(cwd, self.args.config[0]) if not os.path.isfile(config_filename): raise AsyncOrmCommandError("the configuration file does not exist") return configure_orm(config=config_filename)
def test_the_data_is_persistent_orm_model(self): configure_orm({'db_config': db_config, 'apps': ['tests.testapp.appo', 'tests.testapp2']}) # every model declared has the same db_manager self.assertTrue(orm_app.db_manager is Book.objects.db_manager)
def test_ormconfigure_no_db_config(self): with self.assertRaises(AppError) as exc: configure_orm({'apps': ['tests.testapp', 'tests.testapp2']}) self.assertIn('Imposible to configure without database', exc.exception.args[0])
def orm_configure(sanic, loop): # configure_orm defaults to the asyncorm.ini in same directory # the loop is required tho orm = configure_orm(loop=loop) orm.sync_db()
def test_ormconfigure_no_db_config(self): with self.assertRaises(AppError) as exc: configure_orm({"apps": ["tests.testapp", "tests.testapp2"]}) self.assertIn("Imposible to configure without database", exc.exception.args[0])