tests/imei_api.py
def check_output_data(flask_app, i, api_version, include_seen_with_bool=True,
                      class_block_gsma_bool=False, class_block_dupl_bool=False,
                      real_invalid_imei_bool=False, real_gsma_bool=False, class_block_stolen_bool=False,
                      class_informative_malf_bool=False, include_paired_with_bool=True):
    """Helper function used to DRY out IMEI API tests."""
    if api_version == 'v1':
        rv = flask_app.get(url_for('{0}.imei_api'.format(api_version), imei=i,
                                   include_seen_with=include_seen_with_bool,
                                   include_paired_with=include_paired_with_bool))
        assert rv.status_code == 200
        data = json.loads(rv.data.decode('utf-8'))
        expected_norm = i if len(i) < 14 else i[:14]
        assert data['imei_norm'] == expected_norm
        assert data['classification_state']['blocking_conditions']['gsma_not_found'] is class_block_gsma_bool
        assert data['classification_state']['blocking_conditions']['duplicate_mk1'] is class_block_dupl_bool
        assert data['realtime_checks']['invalid_imei'] is real_invalid_imei_bool
        assert data['classification_state']['blocking_conditions']['local_stolen'] is class_block_stolen_bool
        assert data['classification_state']['informative_conditions']['malformed_imei'] is class_informative_malf_bool
        assert data['realtime_checks']['gsma_not_found'] is real_gsma_bool
        assert data['realtime_checks']['in_registration_list'] is False
        return data
Helper function used to DRY out IMEI API tests.
Helper function used to DRY out IMEI API tests.
Helper function used to DRY out IMEI API tests .
def check_output_data(flask_app, i, api_version, include_seen_with_bool=True,
                      class_block_gsma_bool=False, class_block_dupl_bool=False,
                      real_invalid_imei_bool=False, real_gsma_bool=False, class_block_stolen_bool=False,
                      class_informative_malf_bool=False, include_paired_with_bool=True):
    if api_version == 'v1':
        rv = flask_app.get(url_for('{0}.imei_api'.format(api_version), imei=i,
                                   include_seen_with=include_seen_with_bool,
                                   include_paired_with=include_paired_with_bool))
        assert rv.status_code == 200
        data = json.loads(rv.data.decode('utf-8'))
        expected_norm = i if len(i) < 14 else i[:14]
        assert data['imei_norm'] == expected_norm
        assert data['classification_state']['blocking_conditions']['gsma_not_found'] is class_block_gsma_bool
        assert data['classification_state']['blocking_conditions']['duplicate_mk1'] is class_block_dupl_bool
        assert data['realtime_checks']['invalid_imei'] is real_invalid_imei_bool
        assert data['classification_state']['blocking_conditions']['local_stolen'] is class_block_stolen_bool
        assert data['classification_state']['informative_conditions']['malformed_imei'] is class_informative_malf_bool
        assert data['realtime_checks']['gsma_not_found'] is real_gsma_bool
        assert data['realtime_checks']['in_registration_list'] is False
        return data
def check_output_data ( flask_app , i , api_version , include_seen_with_bool = True , class_block_gsma_bool = False , class_block_dupl_bool = False , real_invalid_imei_bool = False , real_gsma_bool = False , class_block_stolen_bool = False , class_informative_malf_bool = False , include_paired_with_bool = True ) : if api_version == 'v1' : rv = flask_app . get ( url_for ( '{0}.imei_api' . format ( api_version ) , imei = i , include_seen_with = include_seen_with_bool , include_paired_with = include_paired_with_bool ) ) assert rv . status_code == 200 data = json . loads ( rv . data . decode ( 'utf-8' ) ) expected_norm = i if len ( i ) < 14 else i [ : 14 ] assert data [ 'imei_norm' ] == expected_norm assert data [ 'classification_state' ] [ 'blocking_conditions' ] [ 'gsma_not_found' ] is class_block_gsma_bool assert data [ 'classification_state' ] [ 'blocking_conditions' ] [ 'duplicate_mk1' ] is class_block_dupl_bool assert data [ 'realtime_checks' ] [ 'invalid_imei' ] is real_invalid_imei_bool assert data [ 'classification_state' ] [ 'blocking_conditions' ] [ 'local_stolen' ] is class_block_stolen_bool assert data [ 'classification_state' ] [ 'informative_conditions' ] [ 'malformed_imei' ] is class_informative_malf_bool assert data [ 'realtime_checks' ] [ 'gsma_not_found' ] is real_gsma_bool assert data [ 'realtime_checks' ] [ 'in_registration_list' ] is False return data
Helper function used to DRY out IMEI API tests.
Helper function used to DRY out IMEI API tests .
"""Helper function used to DRY out IMEI API tests."""
flask_app
i
api_version
include_seen_with_bool
class_block_gsma_bool
class_block_dupl_bool
real_invalid_imei_bool
real_gsma_bool
class_block_stolen_bool
class_informative_malf_bool
include_paired_with_bool