Esempio n. 1
0
def setup(tmpdir, mocker):
    mockargv_config = utils.get_default_argv_config(tmpdir)
    mockargv = mocker.Mock(**mockargv_config)

    pc_config = {'insert.return_value': None, 'update.return_value': None}
    mock_pc = mocker.Mock(**pc_config)

    af_config = {'build_process_control.return_value': mock_pc}
    mock_audit_factory = mocker.Mock(**af_config)
    utils.mock_build_kafka_producer(mocker)

    yield (mockargv, mock_audit_factory)
def setup_no_redolog_dict(tmpdir, mocker):
    mockargv_config = unittest_utils.get_default_argv_config(tmpdir)
    mockargv_config = utils.merge_dicts(
        mockargv_config, {
            'donotload': False,
            'donotsend': False,
            'streamhost': 'host',
            'streamchannel': 'channel',
            'streamschemafile': 'file',
            'streamschemahost': 'host',
            'sourcedictionary': 'redolog'
        })
    mockargv = mocker.Mock(**mockargv_config)
    unittest_utils.setup_logging(mockargv.workdirectory)

    db_config = {'execute_query.side_effect': execute_query_no_redolog_se}
    mockdb = mocker.Mock(**db_config)

    mock_audit_factory = unittest_utils.build_mock_audit_factory(mocker)

    unittest_utils.mock_get_prev_run_cdcs(mocker)
    mock_producer = unittest_utils.mock_build_kafka_producer(mocker)

    yield (OracleCdcExtractor(mockdb, mockargv, mock_audit_factory), mockdb,
           mockargv, mock_producer, 1, 2)
def setup_kill(tmpdir, mocker):
    mockargv_config = unittest_utils.get_default_argv_config(tmpdir)
    mockargv_config = utils.merge_dicts(mockargv_config, {
        'donotload': False,
        'donotsend': False,
        'kill': True
    })
    mockargv = mocker.Mock(**mockargv_config)
    unittest_utils.setup_logging(mockargv.workdirectory)

    db_config = {}
    mockdb = mocker.Mock(**db_config)

    mock_audit_factory = unittest_utils.build_mock_audit_factory(mocker)

    unittest_utils.mock_get_prev_run_cdcs(mocker)
    mock_producer = unittest_utils.mock_build_kafka_producer(mocker)

    yield (OracleCdcExtractor(mockdb, mockargv, mock_audit_factory), mockdb,
           mockargv, mock_producer)
def setup_scn_override(tmpdir, mocker):
    ARGV_STARTSCN = 99
    ARGV_ENDSCN = 100
    mockargv_config = unittest_utils.get_default_argv_config(tmpdir)
    mockargv_config = utils.merge_dicts(mockargv_config, {
        'startscn': ARGV_STARTSCN,
        'endscn': ARGV_ENDSCN,
    })
    mockargv = mocker.Mock(**mockargv_config)

    unittest_utils.setup_logging(mockargv.workdirectory)

    unittest_utils.mock_get_schemas_and_tables(mocker, [], [])

    db_config = {'execute_query.side_effect': default_execute_query_se}
    mockdb = mocker.Mock(**db_config)

    mock_audit_factory = unittest_utils.build_mock_audit_factory(mocker)

    unittest_utils.mock_get_prev_run_cdcs(mocker)
    mock_producer = unittest_utils.mock_build_kafka_producer(mocker)

    yield (OracleCdcExtractor(mockdb, mockargv, mock_audit_factory), mockdb,
           mockargv, ARGV_STARTSCN, ARGV_ENDSCN)