tests/_delta_helpers.py
def delta_remove_check_and_disable_option_common(db_conn, historic_tbl_name, tmpdir, mocked_config, logger,
                                                 importer_name):
    """Common code to verify delta remove check and CLI option to disable it.

    1) Verify that import fails if the check is enabled and the record to remove is not in db.
    2) Verify '--disable-delta-removes-check' CLI option and verify that, if disabled, the import succeeds.
    """
    # write into csv
    csv_imei_change_type_tuples = [('12345678901243', 'remove')]
    # Test part 1)
    valid_zip_import_data_file_path = write_import_csv(tmpdir, importer_name, csv_imei_change_type_tuples)
    runner = CliRunner()
    result = runner.invoke(dirbs_import_cli, [importer_name, '--delta', valid_zip_import_data_file_path],
                           obj={'APP_CONFIG': mocked_config})
    assert result.exit_code == 1
    imei_norm_expected = '12345678901243'
    imei_norm_pk = 'imei_norm'
    if importer_name == 'golden_list':
        imei_norm_expected = imeis_md5_hashing_uuid(imei_norm_expected, convert_to_uuid=True)
        imei_norm_pk = 'hashed_imei_norm'
    assert 'Failed remove delta validation check. Cannot remove records not in db. ' \
           'Failing rows: {imei_norm_pk}: {imei_norm_expected}'.format(imei_norm_pk=imei_norm_pk,
                                                                       imei_norm_expected=imei_norm_expected) \
           in logger_stream_contents(logger)
    # Test part 2)
    result = runner.invoke(dirbs_import_cli, [importer_name, '--delta', '--disable-delta-removes-check',
                                              valid_zip_import_data_file_path], obj={'APP_CONFIG': mocked_config})
    assert result.exit_code == 0
    # historic_table rows
    count, res = fetch_tbl_rows(historic_tbl_name, db_conn)
    assert count == 0
Common code to verify delta remove check and CLI option to disable it.

    1) Verify that import fails if the check is enabled and the record to remove is not in db.
    2) Verify '--disable-delta-removes-check' CLI option and verify that, if disabled, the import succeeds.
    
Common code to verify delta remove check and CLI option to disable it.
1) Verify that import fails if the check is enabled and the record to remove is not in db.
Common code to verify delta remove check and CLI option to disable it . 1 ) Verify that import fails if the check is enabled and the record to remove is not in db .
def delta_remove_check_and_disable_option_common(db_conn, historic_tbl_name, tmpdir, mocked_config, logger,
                                                 importer_name):
    csv_imei_change_type_tuples = [('12345678901243', 'remove')]
    valid_zip_import_data_file_path = write_import_csv(tmpdir, importer_name, csv_imei_change_type_tuples)
    runner = CliRunner()
    result = runner.invoke(dirbs_import_cli, [importer_name, '--delta', valid_zip_import_data_file_path],
                           obj={'APP_CONFIG': mocked_config})
    assert result.exit_code == 1
    imei_norm_expected = '12345678901243'
    imei_norm_pk = 'imei_norm'
    if importer_name == 'golden_list':
        imei_norm_expected = imeis_md5_hashing_uuid(imei_norm_expected, convert_to_uuid=True)
        imei_norm_pk = 'hashed_imei_norm'
    assert 'Failed remove delta validation check. Cannot remove records not in db. ' \
           'Failing rows: {imei_norm_pk}: {imei_norm_expected}'.format(imei_norm_pk=imei_norm_pk,
                                                                       imei_norm_expected=imei_norm_expected) \
           in logger_stream_contents(logger)
    result = runner.invoke(dirbs_import_cli, [importer_name, '--delta', '--disable-delta-removes-check',
                                              valid_zip_import_data_file_path], obj={'APP_CONFIG': mocked_config})
    assert result.exit_code == 0
    count, res = fetch_tbl_rows(historic_tbl_name, db_conn)
    assert count == 0
def delta_remove_check_and_disable_option_common ( db_conn , historic_tbl_name , tmpdir , mocked_config , logger , importer_name ) : csv_imei_change_type_tuples = [ ( '12345678901243' , 'remove' ) ] valid_zip_import_data_file_path = write_import_csv ( tmpdir , importer_name , csv_imei_change_type_tuples ) runner = CliRunner ( ) result = runner . invoke ( dirbs_import_cli , [ importer_name , '--delta' , valid_zip_import_data_file_path ] , obj = { 'APP_CONFIG' : mocked_config } ) assert result . exit_code == 1 imei_norm_expected = '12345678901243' imei_norm_pk = 'imei_norm' if importer_name == 'golden_list' : imei_norm_expected = imeis_md5_hashing_uuid ( imei_norm_expected , convert_to_uuid = True ) imei_norm_pk = 'hashed_imei_norm' assert 'Failed remove delta validation check. Cannot remove records not in db. ' 'Failing rows: {imei_norm_pk}: {imei_norm_expected}' . format ( imei_norm_pk = imei_norm_pk , imei_norm_expected = imei_norm_expected ) in logger_stream_contents ( logger ) result = runner . invoke ( dirbs_import_cli , [ importer_name , '--delta' , '--disable-delta-removes-check' , valid_zip_import_data_file_path ] , obj = { 'APP_CONFIG' : mocked_config } ) assert result . exit_code == 0 count , res = fetch_tbl_rows ( historic_tbl_name , db_conn ) assert count == 0
Common code to verify delta remove check and CLI option to disable it.
Common code to verify delta remove check and CLI option to disable it .
"""Common code to verify delta remove check and CLI option to disable it.

    1) Verify that import fails if the check is enabled and the record to remove is not in db.
    2) Verify '--disable-delta-removes-check' CLI option and verify that, if disabled, the import succeeds.
    """ # write into csv # Test part 1) # Test part 2) # historic_table rows
db_conn
historic_tbl_name
tmpdir
mocked_config
logger
importer_name