def setUp(self) -> None: """Initialise test FastSyncTapPostgres object""" self.postgres = FastSyncTapPostgres( connection_config={'dbname': 'test_database', 'tap_id': 'test_tap'}, tap_type_to_target_type={}, ) self.postgres.executed_queries_primary_host = [] self.postgres.executed_queries = [] def primary_host_query_mock(query, _=None): self.postgres.executed_queries_primary_host.append(query) self.postgres.primary_host_query = primary_host_query_mock
def test_generate_replication_slot_name(self): """Validate if the replication slot name generated correctly""" postgres = FastSyncTapPostgres(connection_config={}, tap_type_to_target_type={}) # Provide only database name assert postgres.generate_replication_slot_name( 'some_db') == 'pipelinewise_some_db' # Provide database name and tap_id assert postgres.generate_replication_slot_name( 'some_db', 'some_tap') == 'pipelinewise_some_db_some_tap' # Provide database name, tap_id and prefix assert postgres.generate_replication_slot_name( 'some_db', 'some_tap', prefix='custom_prefix') == 'custom_prefix_some_db_some_tap' # Replication slot name should be lowercase assert postgres.generate_replication_slot_name( 'SoMe_DB', 'SoMe_TaP') == 'pipelinewise_some_db_some_tap'