-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(postgres): Remove SqlAlchemy dependency from postgres container
Remove test that was testing sqlalchemy support for driver types Add tests for supported versions of Postgres Modify the `get_connection_url` convenience method to support a driverless url Co-authored-by: Jason Turim <jason@opscanvas.com> Co-authored-by: Jan Katins <jasc@gmx.net>
- Loading branch information
Showing
5 changed files
with
73 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
import sqlalchemy | ||
|
||
from testcontainers.postgres import PostgresContainer | ||
|
||
|
||
def test_docker_run_postgres(): | ||
postgres_container = PostgresContainer("postgres:9.5") | ||
with postgres_container as postgres: | ||
engine = sqlalchemy.create_engine(postgres.get_connection_url()) | ||
with engine.begin() as connection: | ||
result = connection.execute(sqlalchemy.text("select version()")) | ||
for row in result: | ||
assert row[0].lower().startswith("postgresql 9.5") | ||
# https://www.postgresql.org/support/versioning/ | ||
supported_versions = ["12", "13", "14", "15", "16", "latest"] | ||
|
||
for version in supported_versions: | ||
postgres_container = PostgresContainer(f"postgres:{version}") | ||
with postgres_container as postgres: | ||
status, msg = postgres.exec(f"pg_isready -hlocalhost -p{postgres.port} -U{postgres.username}") | ||
|
||
def test_docker_run_postgres_with_driver_pg8000(): | ||
postgres_container = PostgresContainer("postgres:9.5", driver="pg8000") | ||
with postgres_container as postgres: | ||
engine = sqlalchemy.create_engine(postgres.get_connection_url()) | ||
with engine.begin() as connection: | ||
connection.execute(sqlalchemy.text("select 1=1")) | ||
assert msg.decode("utf-8").endswith("accepting connections\n") | ||
assert status == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters