tests/_helpers.py
def invoke_cli_classify_with_conditions_helper(conditions_list, mocked_config, monkeypatch,
                                               classify_options=None, curr_date=None, db_conn=None,
                                               expect_success=True, disable_sanity_checks=True):
    """Helper function used to set mocked_config conditon attribute and run the classification command."""
    if not classify_options:
        classify_options = []

    if not curr_date:
        classify_options.extend(['--curr-date', '20161130'])
    else:
        classify_options.extend(['--curr-date', curr_date])

    if disable_sanity_checks:
        classify_options.extend(['--disable-sanity-checks'])

    cond_list = from_cond_dict_list_to_cond_list(conditions_list)

    monkeypatch.setattr(mocked_config, 'conditions', cond_list)
    runner = CliRunner()
    result = runner.invoke(dirbs_classify_cli, classify_options, obj={'APP_CONFIG': mocked_config})
    if expect_success:
        assert result.exit_code == 0
    else:
        assert result.exit_code != 0

    if db_conn:
        matching_imeis = matching_imeis_for_cond_name(db_conn, cond_name=None)
        return matching_imeis
Helper function used to set mocked_config conditon attribute and run the classification command.
Helper function used to set mocked_config conditon attribute and run the classification command.
Helper function used to set mocked_config conditon attribute and run the classification command .
def invoke_cli_classify_with_conditions_helper(conditions_list, mocked_config, monkeypatch,
                                               classify_options=None, curr_date=None, db_conn=None,
                                               expect_success=True, disable_sanity_checks=True):
    if not classify_options:
        classify_options = []
    if not curr_date:
        classify_options.extend(['--curr-date', '20161130'])
    else:
        classify_options.extend(['--curr-date', curr_date])
    if disable_sanity_checks:
        classify_options.extend(['--disable-sanity-checks'])
    cond_list = from_cond_dict_list_to_cond_list(conditions_list)
    monkeypatch.setattr(mocked_config, 'conditions', cond_list)
    runner = CliRunner()
    result = runner.invoke(dirbs_classify_cli, classify_options, obj={'APP_CONFIG': mocked_config})
    if expect_success:
        assert result.exit_code == 0
    else:
        assert result.exit_code != 0
    if db_conn:
        matching_imeis = matching_imeis_for_cond_name(db_conn, cond_name=None)
        return matching_imeis
def invoke_cli_classify_with_conditions_helper ( conditions_list , mocked_config , monkeypatch , classify_options = None , curr_date = None , db_conn = None , expect_success = True , disable_sanity_checks = True ) : if not classify_options : classify_options = [ ] if not curr_date : classify_options . extend ( [ '--curr-date' , '20161130' ] ) else : classify_options . extend ( [ '--curr-date' , curr_date ] ) if disable_sanity_checks : classify_options . extend ( [ '--disable-sanity-checks' ] ) cond_list = from_cond_dict_list_to_cond_list ( conditions_list ) monkeypatch . setattr ( mocked_config , 'conditions' , cond_list ) runner = CliRunner ( ) result = runner . invoke ( dirbs_classify_cli , classify_options , obj = { 'APP_CONFIG' : mocked_config } ) if expect_success : assert result . exit_code == 0 else : assert result . exit_code != 0 if db_conn : matching_imeis = matching_imeis_for_cond_name ( db_conn , cond_name = None ) return matching_imeis
Helper function used to set mocked_config conditon attribute and run the classification command.
Helper function used to set mocked_config conditon attribute and run the classification command .
"""Helper function used to set mocked_config conditon attribute and run the classification command."""
conditions_list
mocked_config
monkeypatch
classify_options
curr_date
db_conn
expect_success
disable_sanity_checks