Beispiel #1
0
def build_cache(app):
    """Build cache."""
    cache.init_app(app)
    with app.app_context():
        cache.clear()
        if not app.config.get('TESTING', False):
            try:
                from pay_api.services.code import Code as CodeService  # pylint: disable=import-outside-toplevel
                CodeService.build_all_codes_cache()
            except Exception as e:  # NOQA pylint:disable=broad-except
                app.logger.error('Error on caching ')
                app.logger.error(e)
Beispiel #2
0
def test_find_code_value_by_type_and_code(session):
    """Assert that code values are returned."""
    codes = CodeService.find_code_values_by_type(Code.ERROR.value)
    first_code = codes.get('codes')[0].get('type')
    cache.clear()
    code = CodeService.find_code_value_by_type_and_code(
        Code.ERROR.value, first_code)
    assert code is not None
    assert code.get('type') == first_code

    codes = CodeService.find_code_values_by_type(Code.PAYMENT_STATUS.value)
    first_code = codes.get('codes')[0].get('type')
    cache.clear()
    code = CodeService.find_code_value_by_type_and_code(
        Code.PAYMENT_STATUS.value, first_code)
    assert code is not None
    assert code.get('type') == first_code