From 54079072db3a6ff0794b8ce141e2dd929416bd14 Mon Sep 17 00:00:00 2001 From: Oleksandr Shulgin Date: Wed, 14 Oct 2015 12:43:26 +0200 Subject: [PATCH] Fix ReplicationTest: no NotSupportedError now. --- tests/test_connection.py | 18 +++++++++++++----- tests/testconfig.py | 4 +--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index 68bb6f05..91ea51f5 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1180,14 +1180,22 @@ class AutocommitTests(ConnectingTestCase): class ReplicationTest(ConnectingTestCase): @skip_before_postgres(9, 0) - def test_replication_not_supported(self): - conn = self.repl_connect() + def test_physical_replication_connection(self): + import psycopg2.extras + conn = self.repl_connect(connection_factory=psycopg2.extras.PhysicalReplicationConnection) if conn is None: return cur = conn.cursor() - f = StringIO() - self.assertRaises(psycopg2.NotSupportedError, - cur.copy_expert, "START_REPLICATION 0/0", f) + cur.execute("IDENTIFY_SYSTEM") + cur.fetchall() + @skip_before_postgres(9, 4) + def test_logical_replication_connection(self): + import psycopg2.extras + conn = self.repl_connect(connection_factory=psycopg2.extras.LogicalReplicationConnection) + if conn is None: return + cur = conn.cursor() + cur.execute("IDENTIFY_SYSTEM") + cur.fetchall() def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) diff --git a/tests/testconfig.py b/tests/testconfig.py index 0f995fbf..d59e5a0d 100644 --- a/tests/testconfig.py +++ b/tests/testconfig.py @@ -7,8 +7,6 @@ dbhost = os.environ.get('PSYCOPG2_TESTDB_HOST', None) dbport = os.environ.get('PSYCOPG2_TESTDB_PORT', None) dbuser = os.environ.get('PSYCOPG2_TESTDB_USER', None) dbpass = os.environ.get('PSYCOPG2_TESTDB_PASSWORD', None) -repl_dsn = os.environ.get('PSYCOPG2_TEST_REPL_DSN', - "dbname=psycopg2_test replication=1") # Check if we want to test psycopg's green path. green = os.environ.get('PSYCOPG2_TEST_GREEN', None) @@ -35,4 +33,4 @@ if dbuser is not None: if dbpass is not None: dsn += ' password=%s' % dbpass - +repl_dsn = os.environ.get('PSYCOPG2_TEST_REPL_DSN', dsn)