Ejemplo n.º 1
0
def test_get_schema_path_map():
    schema_path_map = get_schema_path_map()

    assert all(
        language_code in schema_path_map.keys() for language_code in ["en", "cy"]
    )
    assert all(os.path.exists(path) for path in schema_path_map["en"].values())
Ejemplo n.º 2
0
def test_get_schema_path_map():
    schema_path_map = get_schema_path_map(include_test_schemas=True)

    assert all(language_code in schema_path_map.keys()
               for language_code in ["en", "cy"])
    assert all(os.path.exists(path) for path in schema_path_map["en"].values())
    assert all(
        os.path.basename(path).replace(".json", "") == schema_name
        for schema_name, path in schema_path_map["en"].items())
Ejemplo n.º 3
0
def test_schema_cache_on_app_start_up():
    _load_schema_from_name.cache_clear()
    cache_info = _load_schema_from_name.cache_info()
    assert cache_info.currsize == 0
    assert cache_info.hits == 0

    # create app and load schemas into cache
    create_app()

    total_schemas = sum(
        len(schemas)
        for schemas in get_schema_path_map(include_test_schemas=True).values())
    cache_info = _load_schema_from_name.cache_info()
    assert cache_info.currsize > 0 and cache_info.currsize == total_schemas
    assert cache_info.hits == 0

    # loads schema again to fetch from cache
    cache_questionnaire_schemas()
    cache_info = _load_schema_from_name.cache_info()
    assert cache_info.currsize == total_schemas
    assert cache_info.hits == total_schemas