Skip to content

Commit 70055bc

Browse files
annabaasanna
andauthored
Feature/add greenplum (#119)
* Add parameters to Postgress testcontainer to enable Greenplum support * Add parameters to Postgress testcontainer to enable Greenplum support * Shorten length of line to pass flake8 test Co-authored-by: anna <[email protected]>
1 parent ebcbd72 commit 70055bc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

testcontainers/postgres.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ class PostgresContainer(DbContainer):
3232
POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD", "test")
3333
POSTGRES_DB = os.environ.get("POSTGRES_DB", "test")
3434

35-
def __init__(self, image="postgres:latest"):
35+
def __init__(self, image="postgres:latest", port=5432, user=None, password=None, dbname=None):
3636
super(PostgresContainer, self).__init__(image=image)
37-
self.port_to_expose = 5432
37+
self.POSTGRES_USER = user or self.POSTGRES_USER
38+
self.POSTGRES_PASSWORD = password or self.POSTGRES_PASSWORD
39+
self.POSTGRES_DB = dbname or self.POSTGRES_DB
40+
self.port_to_expose = port
41+
3842
self.with_exposed_ports(self.port_to_expose)
3943

4044
def _configure(self):

tests/test_db_containers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ def test_docker_run_postgress():
3131
print("server version:", row[0])
3232

3333

34+
def test_docker_run_greenplum():
35+
postgres_container = PostgresContainer("datagrip/greenplum:6.8",
36+
user="guest", password="guest", dbname="guest")
37+
with postgres_container as postgres:
38+
e = sqlalchemy.create_engine(postgres.get_connection_url())
39+
result = e.execute("select version()")
40+
for row in result:
41+
print("server version:", row[0])
42+
43+
3444
def test_docker_run_mariadb():
3545
mariadb_container = MySqlContainer("mariadb:10.2.9")
3646
with mariadb_container as mariadb:

0 commit comments

Comments
 (0)