def __init__(self, config: datastore_pb2.DataStore): self._config = config self._engine = db.MakeEngine(self._config) db.Table.metadata.create_all(self._engine) db.Table.metadata.bind = self._engine self._make_session = orm.sessionmaker(bind=self._engine)
def test_MakeEngine_mysql_database_backtick(): config = DataStoreProtoMock() config.HasField = lambda x: x == 'mysql' config.mysql.database = 'backtick`' with pytest.raises(db.InvalidDatabaseConfig): db.MakeEngine(config)
def test_MakeEngine_postgresql_database_quote(): config = DataStoreProtoMock() config.HasField = lambda x: x == 'postgresql' config.postgresql.database = "singlequote'" with pytest.raises(db.InvalidDatabaseConfig): db.MakeEngine(config)
def test_MakeEngine_unknown_backend(): with pytest.raises(NotImplementedError): db.MakeEngine(DataStoreProtoMock())
def test_MakeEngine_mysql_database_backtick(): config = DataStoreProtoMock() config.HasField = lambda x: x == "mysql" config.mysql.database = "backtick`" with test.Raises(db.InvalidDatabaseConfig): db.MakeEngine(config)