def test_should_create_persistence_with_sqlite_database(): filename = ModelFilenameMother.get("sql/persistence.sql.models.yml") connection = SqliteConnection.create(server_name="sqlite", database_name="petisco.db") database = SqliteDatabase(name="sqlite_test", connection=connection, model_filename=filename) persistence = Persistence() persistence.add(database) persistence.create() assert database.info() == { "name": "sqlite_test", "models": { "client": "tests.modules.persistence.ymls.sql.models.ClientModel", "product": "tests.modules.persistence.ymls.sql.models.ProductModel", "user": "******", }, } assert Persistence.is_available() persistence.delete() Persistence.clear()
def test_should_create_persistence_with_elastic_database(): connection = ElasticConnection.create_local() database = ElasticDatabase(name="elastic_test", connection=connection) Persistence.clear() persistence = Persistence() persistence.add(database) assert database.info() == {"name": "elastic_test"} persistence.create() assert Persistence.is_available() persistence.delete() Persistence.clear()
def test_should_persistence_not_available_when_no_database_is_added(): Persistence.clear() assert not Persistence.is_available()