Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /limber-project_limberframework /tests /database /test_connections.py
| from pytest import mark, raises | |
| from sqlalchemy.engine import Engine | |
| from limberframework.database.connections import ( | |
| PostgresConnection, | |
| SqliteConnection, | |
| make_connection, | |
| ) | |
| def test_postgres_connection(config): | |
| postgres_connection = PostgresConnection(**config) | |
| assert isinstance(postgres_connection, PostgresConnection) | |
| assert isinstance(postgres_connection.engine, Engine) | |
| assert postgres_connection.username == config["username"] | |
| assert postgres_connection.password == config["password"] | |
| assert postgres_connection.host == config["host"] | |
| assert postgres_connection.port == config["port"] | |
| assert postgres_connection.database == config["database"] | |
| def test_sqlite_connection(path): | |
| sqlite_connection = SqliteConnection(path) | |
| assert isinstance(sqlite_connection, SqliteConnection) | |
| assert isinstance(sqlite_connection.engine, Engine) | |
| assert sqlite_connection.path == path | |
| def test_pgsql_connection_get_url(config, expected_url): | |
| postgres_connection = PostgresConnection(**config) | |
| url = postgres_connection.get_url() | |
| assert expected_url in url | |
| def test_sqlite_connection_get_url(path, expected_url): | |
| sqlite_connection = SqliteConnection(path) | |
| url = sqlite_connection.get_url() | |
| assert expected_url in url | |
| async def test_make_connection_with_invalid_config(): | |
| config = {"driver": "sqlite"} | |
| with raises(KeyError) as exception: | |
| await make_connection(config) | |
| assert "path" in str(exception.value) | |
| async def test_make_connection_with_invalid_driver(): | |
| config = {"driver": "invalid_driver"} | |
| with raises(Exception) as exception: | |
| await make_connection(config) | |
| assert f"Unsupported driver {config['driver']}" in str(exception.value) | |
| async def test_make_connection_pgsql(): | |
| config = { | |
| "driver": "pgsql", | |
| "username": "test", | |
| "password": "test", | |
| "host": "test", | |
| "port": 5432, | |
| "database": "test", | |
| } | |
| response = await make_connection(config) | |
| assert isinstance(response, PostgresConnection) | |
Xet Storage Details
- Size:
- 3.59 kB
- Xet hash:
- 28e5e87a1e2137a90051ccd8dd698383026b8823c49f3b8d960e93f1adcfc586
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.