@@ -63,12 +63,14 @@ def test_ensure_replication_slot_exists_returns_false_when_slot_exists(self, moc
6363 self .assertIn ("FROM pg_catalog.pg_replication_slots" , mock_query_singleton .call_args [0 ][1 ])
6464 mock_conn .close .assert_called_once_with ()
6565
66- @patch ('gppylib.commands.pg.dbconn.querySingleton' , side_effect = [0 , 'slot_name' ])
66+ @patch ('gppylib.commands.pg.dbconn.execSQL' )
67+ @patch ('gppylib.commands.pg.dbconn.querySingleton' , return_value = 0 )
6768 @patch ('gppylib.commands.pg.dbconn.connect' )
6869 @patch ('gppylib.commands.pg.dbconn.DbURL' )
6970 def test_ensure_replication_slot_exists_creates_missing_slot (self , mock_dburl ,
7071 mock_connect ,
71- mock_query_singleton ):
72+ mock_query_singleton ,
73+ mock_exec_sql ):
7274 mock_conn = Mock ()
7375 mock_connect .return_value = mock_conn
7476
@@ -77,10 +79,11 @@ def test_ensure_replication_slot_exists_creates_missing_slot(self, mock_dburl,
7779 self .assertTrue (created )
7880 mock_dburl .assert_called_once_with (hostname = 'source-host' , port = 5432 , dbname = 'template1' )
7981 mock_connect .assert_called_once_with (mock_dburl .return_value , utility = True )
80- self .assertEqual (2 , mock_query_singleton .call_count )
81- self .assertIn ("FROM pg_catalog.pg_replication_slots" , mock_query_singleton .call_args_list [0 ][0 ][1 ])
82+ self .assertEqual (1 , mock_query_singleton .call_count )
83+ self .assertIn ("FROM pg_catalog.pg_replication_slots" , mock_query_singleton .call_args [0 ][1 ])
84+ mock_exec_sql .assert_called_once ()
8285 self .assertIn ("pg_create_physical_replication_slot('slot_name')" ,
83- mock_query_singleton . call_args_list [ 1 ] [0 ][1 ])
86+ mock_exec_sql . call_args [0 ][1 ])
8487 mock_conn .close .assert_called_once_with ()
8588
8689 @patch ('gppylib.commands.pg.dbconn.querySingleton' )
0 commit comments