Skip to content

Commit 953a616

Browse files
author
András Váczi
committed
Fix existing tests
1 parent a0ab28e commit 953a616

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

tests/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class MockPatroni(object):
159159
noloadbalance = PropertyMock(return_value=False)
160160
scheduled_restart = {'schedule': future_restart_time,
161161
'postmaster_start_time': postgresql.postmaster_start_time()}
162+
multisite = Mock()
162163

163164
@staticmethod
164165
def sighup_handler():

tests/test_ctl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ def test_output_members(self):
121121
with click.Context(click.Command('list')) as ctx:
122122
ctx.obj = {'__config': {}, '__mpp': get_mpp({})}
123123
scheduled_at = datetime.now(tzutc) + timedelta(seconds=600)
124-
cluster = get_cluster_initialized_with_leader(Failover(1, 'foo', 'bar', scheduled_at))
124+
target_site = 'baz'
125+
cluster = get_cluster_initialized_with_leader(Failover(1, 'foo', 'bar', scheduled_at, target_site))
125126
del cluster.members[1].data['conn_url']
126127
for fmt in ('pretty', 'json', 'yaml', 'topology'):
127128
self.assertIsNone(output_members(cluster, name='abc', fmt=fmt))
@@ -555,8 +556,10 @@ def test_flush_switchover(self):
555556
assert 'No pending scheduled switchover' in result.output
556557

557558
scheduled_at = datetime.now(tzutc) + timedelta(seconds=600)
559+
target_site = 'baz'
558560
with patch('patroni.dcs.AbstractDCS.get_cluster',
559-
Mock(return_value=get_cluster_initialized_with_leader(Failover(1, 'a', 'b', scheduled_at)))):
561+
Mock(return_value=get_cluster_initialized_with_leader(Failover(1, 'a', 'b', scheduled_at,
562+
target_site)))):
560563
result = self.runner.invoke(ctl, ['-k', 'flush', 'dummy', 'switchover'])
561564
assert result.output.startswith('Success: ')
562565

tests/test_ha.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from patroni.postgresql.sync import _SyncState
2525
from patroni.utils import tzutc
2626
from patroni.watchdog import Watchdog
27+
from patroni.multisite import SingleSiteController
2728

2829
from . import MockPostmaster, PostgresInit, psycopg_connect, requests_get
2930
from .test_etcd import etcd_read, etcd_write, socket_getaddrinfo
@@ -156,6 +157,7 @@ def __init__(self, p, d):
156157
self.watchdog = Watchdog(self.config)
157158
self.request = lambda *args, **kwargs: requests_get(args[0].api_url, *args[1:], **kwargs)
158159
self.failover_priority = 1
160+
self.multisite = SingleSiteController()
159161

160162

161163
def run_async(self, func, args=()):

0 commit comments

Comments
 (0)