tests/_delta_helpers.py
def multiple_changes_check_common(logger, mocked_config, tmpdir, importer_name):
    """Common code to verify that is not possible to add and remove a record at the same time."""
    # write into csv
    csv_imei_change_type_tuples = [('12345678901234', 'add'), ('12345678901234', '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 = '12345678901234'
    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 'Same record cannot be added or removed at the same time in delta list. ' \
           '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)
Common code to verify that is not possible to add and remove a record at the same time.
Common code to verify that is not possible to add and remove a record at the same time.
Common code to verify that is not possible to add and remove a record at the same time .
def multiple_changes_check_common(logger, mocked_config, tmpdir, importer_name):
    csv_imei_change_type_tuples = [('12345678901234', 'add'), ('12345678901234', '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 = '12345678901234'
    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 'Same record cannot be added or removed at the same time in delta list. ' \
           '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)
def multiple_changes_check_common ( logger , mocked_config , tmpdir , importer_name ) : csv_imei_change_type_tuples = [ ( '12345678901234' , 'add' ) , ( '12345678901234' , '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 = '12345678901234' 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 'Same record cannot be added or removed at the same time in delta list. ' '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 )
Common code to verify that is not possible to add and remove a record at the same time.
Common code to verify that is not possible to add and remove a record at the same time .
"""Common code to verify that is not possible to add and remove a record at the same time.""" # write into csv
logger
mocked_config
tmpdir
importer_name