tests/_delta_helpers.py
def historic_threshold_config_common(postgres, db_conn, tmpdir, mocked_config, logger, importer_name,
                                     historic_tbl_name, monkeypatch):
    """Test Depot not available yet. Verify that historic treeshold is configurable by yaml."""
    historic_threshold_to_importers = {'pairing_list': 'pairing_threshold_config',
                                       'stolen_list': 'stolen_threshold_config',
                                       'registration_list': 'import_threshold_config',
                                       'golden_list': 'golden_threshold_config'}

    hist_thr = historic_threshold_to_importers.get(importer_name, '')
    monkeypatch.setattr(getattr(mocked_config, hist_thr, ''), 'import_size_variation_absolute', 0.3, raising=False)
    monkeypatch.setattr(getattr(mocked_config, hist_thr, ''), 'import_size_variation_percent', 0.3, raising=False)

    valid_zip_import_data_file_path = write_import_csv(tmpdir, importer_name, [('22345678901243', 'add')])
    runner = CliRunner()
    runner.invoke(dirbs_import_cli, [importer_name, '--delta', valid_zip_import_data_file_path],
                  obj={'APP_CONFIG': mocked_config})

    with db_conn, db_conn.cursor() as cur:
        cur.execute("""SELECT extra_metadata->'historic_size_variation_max_pct' AS historic_size_variation_max_pct,
                              extra_metadata->'historic_size_variation_max_abs' AS historic_size_variation_max_abs
                         FROM job_metadata
                        WHERE command = \'dirbs-import\'""")  # noqa Q444
        res = cur.fetchall()
        assert len(res) == 1
        res[0].historic_size_variation_max_pct == 0.3
        res[0].historic_size_variation_max_abs == 0.3
Test Depot not available yet. Verify that historic treeshold is configurable by yaml.
Test Depot not available yet. Verify that historic treeshold is configurable by yaml.
Test Depot not available yet . Verify that historic treeshold is configurable by yaml .
def historic_threshold_config_common(postgres, db_conn, tmpdir, mocked_config, logger, importer_name,
                                     historic_tbl_name, monkeypatch):
    historic_threshold_to_importers = {'pairing_list': 'pairing_threshold_config',
                                       'stolen_list': 'stolen_threshold_config',
                                       'registration_list': 'import_threshold_config',
                                       'golden_list': 'golden_threshold_config'}
    hist_thr = historic_threshold_to_importers.get(importer_name, '')
    monkeypatch.setattr(getattr(mocked_config, hist_thr, ''), 'import_size_variation_absolute', 0.3, raising=False)
    monkeypatch.setattr(getattr(mocked_config, hist_thr, ''), 'import_size_variation_percent', 0.3, raising=False)
    valid_zip_import_data_file_path = write_import_csv(tmpdir, importer_name, [('22345678901243', 'add')])
    runner = CliRunner()
    runner.invoke(dirbs_import_cli, [importer_name, '--delta', valid_zip_import_data_file_path],
                  obj={'APP_CONFIG': mocked_config})
    with db_conn, db_conn.cursor() as cur:
        cur.execute("""SELECT extra_metadata->'historic_size_variation_max_pct' AS historic_size_variation_max_pct,
                              extra_metadata->'historic_size_variation_max_abs' AS historic_size_variation_max_abs
                         FROM job_metadata
                        WHERE command = \'dirbs-import\'""")  
        res = cur.fetchall()
        assert len(res) == 1
        res[0].historic_size_variation_max_pct == 0.3
        res[0].historic_size_variation_max_abs == 0.3
def historic_threshold_config_common ( postgres , db_conn , tmpdir , mocked_config , logger , importer_name , historic_tbl_name , monkeypatch ) : historic_threshold_to_importers = { 'pairing_list' : 'pairing_threshold_config' , 'stolen_list' : 'stolen_threshold_config' , 'registration_list' : 'import_threshold_config' , 'golden_list' : 'golden_threshold_config' } hist_thr = historic_threshold_to_importers . get ( importer_name , '' ) monkeypatch . setattr ( getattr ( mocked_config , hist_thr , '' ) , 'import_size_variation_absolute' , 0.3 , raising = False ) monkeypatch . setattr ( getattr ( mocked_config , hist_thr , '' ) , 'import_size_variation_percent' , 0.3 , raising = False ) valid_zip_import_data_file_path = write_import_csv ( tmpdir , importer_name , [ ( '22345678901243' , 'add' ) ] ) runner = CliRunner ( ) runner . invoke ( dirbs_import_cli , [ importer_name , '--delta' , valid_zip_import_data_file_path ] , obj = { 'APP_CONFIG' : mocked_config } ) with db_conn , db_conn . cursor ( ) as cur : cur . execute ( """SELECT extra_metadata->'historic_size_variation_max_pct' AS historic_size_variation_max_pct,
                              extra_metadata->'historic_size_variation_max_abs' AS historic_size_variation_max_abs
                         FROM job_metadata
                        WHERE command = \'dirbs-import\'""" ) res = cur . fetchall ( ) assert len ( res ) == 1 res [ 0 ] . historic_size_variation_max_pct == 0.3 res [ 0 ] . historic_size_variation_max_abs == 0.3
Test Depot not available yet.
Test Depot not available yet .
"""Test Depot not available yet. Verify that historic treeshold is configurable by yaml.""" # noqa Q444
postgres
db_conn
tmpdir
mocked_config
logger
importer_name
historic_tbl_name
monkeypatch