Skip to content

Commit 78c5a89

Browse files
committed
increase coverage
1 parent d951ab7 commit 78c5a89

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

dlairflow/test/test_postgresql.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"""Test dlairflow.postgresql.
44
"""
55
import os
6+
import warnings
67
from ..postgresql import pg_dump_schema, pg_restore_schema
78
from airflow.hooks.base import BaseHook
9+
from airflow.operators.bash import BashOperator
810

911

1012
class MockConnection(object):
@@ -29,7 +31,9 @@ def mock_connection(connection):
2931

3032
test_operator = pg_dump_schema("login,password,host,schema", "dump_schema")
3133

32-
print(dir(test_operator))
34+
assert isinstance(test_operator, BashOperator)
35+
assert test_operator.env['PGHOST'] == 'host'
36+
assert test_operator.params['schema'] == 'dump_schema'
3337

3438

3539
def test_pg_dump_schema_alt_dir(monkeypatch):
@@ -43,4 +47,38 @@ def mock_connection(connection):
4347

4448
test_operator = pg_dump_schema("login,password,host,schema", "dump_schema", "dump_dir")
4549

46-
print(dir(test_operator))
50+
assert isinstance(test_operator, BashOperator)
51+
assert test_operator.env['PGHOST'] == 'host'
52+
assert test_operator.params['dump_dir'] == 'dump_dir'
53+
54+
55+
def test_pg_restore_schema(monkeypatch):
56+
"""Test pg_restore task.
57+
"""
58+
def mock_connection(connection):
59+
conn = MockConnection(connection)
60+
return conn
61+
62+
monkeypatch.setattr(BaseHook, "get_connection", mock_connection)
63+
64+
test_operator = pg_restore_schema("login,password,host,schema", "dump_schema")
65+
66+
assert isinstance(test_operator, BashOperator)
67+
assert test_operator.env['PGHOST'] == 'host'
68+
assert test_operator.params['schema'] == 'dump_schema'
69+
70+
71+
def test_pg_dump_schema_alt_dir(monkeypatch):
72+
"""Test pg_restore task with alternate directory.
73+
"""
74+
def mock_connection(connection):
75+
conn = MockConnection(connection)
76+
return conn
77+
78+
monkeypatch.setattr(BaseHook, "get_connection", mock_connection)
79+
80+
test_operator = pg_restore_schema("login,password,host,schema", "dump_schema", "dump_dir")
81+
82+
assert isinstance(test_operator, BashOperator)
83+
assert test_operator.env['PGHOST'] == 'host'
84+
assert test_operator.params['dump_dir'] == 'dump_dir'

0 commit comments

Comments
 (0)