Example #1
0
 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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
def test_MakeEngine_unknown_backend():
    with pytest.raises(NotImplementedError):
        db.MakeEngine(DataStoreProtoMock())
Example #5
0
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)