Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 15ccedb

Browse files
committed
more tests
1 parent 5d5b471 commit 15ccedb

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

tests/test_simple.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
ExecUtilException, \
2020
BackupException, \
2121
QueryException, \
22-
CatchUpException
22+
CatchUpException, \
23+
TimeoutException
2324

2425
from testgres import get_new_node, get_pg_config, configure_testgres
2526
from testgres import bound_ports
@@ -60,22 +61,58 @@ def test_restart(self):
6061
res = node.execute('postgres', 'select 2')
6162
self.assertEqual(res, [(2, )])
6263

64+
def test_psql(self):
65+
with get_new_node('test') as node:
66+
node.init().start()
67+
68+
# check default params
69+
got_exception = False
70+
try:
71+
node.psql('postgres')
72+
except QueryException as e:
73+
got_exception = True
74+
self.assertTrue(got_exception)
75+
76+
# check returned values
77+
res = node.psql('postgres', 'select 1')
78+
self.assertEqual(res[0], 0)
79+
self.assertEqual(res[1], b'1\n')
80+
self.assertEqual(res[2], b'')
81+
82+
# check returned values
83+
res = node.safe_psql('postgres', 'select 1')
84+
self.assertEqual(res, b'1\n')
85+
86+
node.stop()
87+
88+
# check psql on stopped node
89+
got_exception = False
90+
try:
91+
node.safe_psql('postgres', 'select 1')
92+
except QueryException as e:
93+
got_exception = True
94+
self.assertTrue(got_exception)
95+
6396
def test_status(self):
97+
# check NodeStatus cast to bool
6498
condition_triggered = False
6599
if NodeStatus.Running:
66100
condition_triggered = True
67101
self.assertTrue(condition_triggered)
68102

103+
# check NodeStatus cast to bool
69104
condition_triggered = False
70105
if NodeStatus.Stopped:
71106
condition_triggered = True
72107
self.assertFalse(condition_triggered)
73108

109+
# check NodeStatus cast to bool
74110
condition_triggered = False
75111
if NodeStatus.Uninitialized:
76112
condition_triggered = True
77113
self.assertFalse(condition_triggered)
78114

115+
# check statuses after each operation
79116
with get_new_node('test') as node:
80117
self.assertEqual(node.get_pid(), 0)
81118
self.assertEqual(node.status(), NodeStatus.Uninitialized)
@@ -336,6 +373,17 @@ def test_poll_query_until(self):
336373
got_exception = True
337374
self.assertTrue(got_exception)
338375

376+
# check timeout
377+
got_exception = False
378+
try:
379+
node.poll_query_until(dbname='postgres',
380+
query='select 1 > 2',
381+
max_attempts=5,
382+
sleep_time=0.2)
383+
except TimeoutException as e:
384+
got_exception = True
385+
self.assertTrue(got_exception)
386+
339387
def test_logging(self):
340388
logfile = tempfile.NamedTemporaryFile('w', delete=True)
341389

0 commit comments

Comments
 (0)