def test_client_with_montydb_uri(gettempdir): URI_SCHEME_PREFIX # Faltfile tmp_dir = os.path.join(gettempdir, "flatfile") uri = URI_SCHEME_PREFIX + tmp_dir set_storage(repository=uri, storage="flatfile") client = montydb.MontyClient(uri) assert client.address == tmp_dir # SQLite tmp_dir = os.path.join(gettempdir, "sqlite") uri = URI_SCHEME_PREFIX + tmp_dir set_storage(repository=uri, storage="sqlite") client = montydb.MontyClient(uri) assert client.address == tmp_dir # Memory uri = URI_SCHEME_PREFIX + MEMORY_REPOSITORY client = montydb.MontyClient(uri) assert client.address == MEMORY_REPOSITORY
def test_configure_get_storage_engine(tmp_config_repo): # Faltfile tmp_dir = os.path.join(tmp_config_repo, "flatfile") set_storage(repository=tmp_dir, storage="flatfile") storage_cls = provide_storage(repository=tmp_dir) storage = storage_cls.launch(tmp_dir) assert isinstance(storage, FlatFileStorage) # SQLite tmp_dir = os.path.join(tmp_config_repo, "sqlite") set_storage(repository=tmp_dir, storage="sqlite") storage_cls = provide_storage(repository=tmp_dir) storage = storage_cls.launch(tmp_dir) assert isinstance(storage, SQLiteStorage) # Memory storage_cls = provide_storage(repository=":memory:") storage = storage_cls.launch(":memory:") assert isinstance(storage, MemoryStorage)
def test_set_storage_to_memory(): with pytest.raises(ConfigurationError): set_storage(storage="memory")