mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	Fix PSYCOPG2_TEST_REPL_DSN handling.
This commit is contained in:
		
							parent
							
								
									cf4f2411bf
								
							
						
					
					
						commit
						0435320f34
					
				| 
						 | 
					@ -33,6 +33,9 @@ from testutils import ConnectingTestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ReplicationTestCase(ConnectingTestCase):
 | 
					class ReplicationTestCase(ConnectingTestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
 | 
					        from testconfig import repl_dsn
 | 
				
			||||||
 | 
					        if not repl_dsn:
 | 
				
			||||||
 | 
					            self.skipTest("replication tests disabled by default")
 | 
				
			||||||
        super(ReplicationTestCase, self).setUp()
 | 
					        super(ReplicationTestCase, self).setUp()
 | 
				
			||||||
        self._slots = []
 | 
					        self._slots = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,6 +102,19 @@ class ReplicationTest(ReplicationTestCase):
 | 
				
			||||||
        self.create_replication_slot(cur, slot)
 | 
					        self.create_replication_slot(cur, slot)
 | 
				
			||||||
        self.assertRaises(psycopg2.ProgrammingError, self.create_replication_slot, cur, slot)
 | 
					        self.assertRaises(psycopg2.ProgrammingError, self.create_replication_slot, cur, slot)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @skip_before_postgres(9, 4) # slots require 9.4
 | 
				
			||||||
 | 
					    def test_start_on_missing_replication_slot(self):
 | 
				
			||||||
 | 
					        conn = self.repl_connect(connection_factory=PhysicalReplicationConnection)
 | 
				
			||||||
 | 
					        if conn is None: return
 | 
				
			||||||
 | 
					        cur = conn.cursor()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        slot = "test_slot1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.assertRaises(psycopg2.ProgrammingError, cur.start_replication, slot)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.create_replication_slot(cur, slot)
 | 
				
			||||||
 | 
					        cur.start_replication(slot)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AsyncReplicationTest(ReplicationTestCase):
 | 
					class AsyncReplicationTest(ReplicationTestCase):
 | 
				
			||||||
    @skip_before_postgres(9, 4)
 | 
					    @skip_before_postgres(9, 4)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,4 +33,8 @@ if dbuser is not None:
 | 
				
			||||||
if dbpass is not None:
 | 
					if dbpass is not None:
 | 
				
			||||||
    dsn += ' password=%s' % dbpass
 | 
					    dsn += ' password=%s' % dbpass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
repl_dsn = os.environ.get('PSYCOPG2_TEST_REPL_DSN', dsn)
 | 
					# Don't run replication tests if REPL_DSN is not set, default to normal DSN if
 | 
				
			||||||
 | 
					# set to empty string.
 | 
				
			||||||
 | 
					repl_dsn = os.environ.get('PSYCOPG2_TEST_REPL_DSN', None)
 | 
				
			||||||
 | 
					if repl_dsn == '':
 | 
				
			||||||
 | 
					    repl_dsn = dsn
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user