Skip to content

Commit 670fb10

Browse files
committed
Make non-temp cluster usable with tests again
1 parent c9de630 commit 670fb10

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

asyncpg/cluster.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def __init__(self, data_dir, *, pg_config_path=None):
7878
self._daemon_process = None
7979
self._connection_addr = None
8080

81+
def is_managed(self):
82+
return True
83+
8184
def get_data_dir(self):
8285
return self._data_dir
8386

@@ -448,13 +451,15 @@ def __init__(self, host=None, port=None):
448451
self.host = host
449452
self.port = port
450453

454+
def is_managed(self):
455+
return False
456+
457+
def get_connection_addr(self):
458+
return self.host, self.port
459+
451460
def get_status(self):
452461
return 'running'
453462

454-
async def connect(self, loop=None, **kwargs):
455-
return await asyncpg.connect(
456-
host=self.host, port=self.port, loop=loop, **kwargs)
457-
458463
def init(self, **settings):
459464
pass
460465

@@ -466,3 +471,10 @@ def stop(self, wait=60):
466471

467472
def destroy(self):
468473
pass
474+
475+
def reset_hba(self):
476+
raise ClusterError('cannot modify HBA records of unmanaged cluster')
477+
478+
def add_hba_entry(self, *, type='host', database, user, address=None,
479+
auth_method, auth_options=None):
480+
raise ClusterError('cannot modify HBA records of unmanaged cluster')

tests/test_connect.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class TestAuthentication(tb.ConnectedTestCase):
2727
def setUp(self):
2828
super().setUp()
2929

30+
if not self.cluster.is_managed():
31+
self.skipTest('unmanaged cluster')
32+
3033
methods = [
3134
('trust', None),
3235
('reject', None),

0 commit comments

Comments
 (0)