-
Notifications
You must be signed in to change notification settings - Fork 299
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 <[email protected]> Co-authored-by: Jan Katins <[email protected]>
- Loading branch information
Showing
6 changed files
with
80 additions
and
33 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,19 @@ | ||
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}") | ||
|
||
assert msg.decode("utf-8").endswith("accepting connections\n") | ||
assert status == 0 | ||
|
||
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")) | ||
status, msg = postgres.exec(f"psql -hlocalhost -p{postgres.port} -U{postgres.username} -c 'select 2*3*5*7*11*13*17 as a;' ") | ||
assert "510510" in msg.decode("utf-8") | ||
assert "(1 row)" in msg.decode("utf-8") | ||
assert status == 0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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