Esempio n. 1
0
async def server(aiohttp_server):
    """Setup testing app."""
    app = create_app({DEFAULT_PATH + "/v1": "webapp.v1.spec.yaml",
                      DEFAULT_PATH + "/v2": "webapp.v2.spec.yaml",
                      DEFAULT_PATH + "/v3": "webapp.v3.spec.yaml",
                      DEFAULT_PATH_API + "/v1": "webapp.v1.spec.yaml",
                      DEFAULT_PATH_API + "/v2": "webapp.v2.spec.yaml",
                      DEFAULT_PATH_API + "/v3": "webapp.v3.spec.yaml"})
    BaseHandler.db_cache = yaml_cache.load_test_cache()
    load_cache_to_apis()
    return await aiohttp_server(app.app)
Esempio n. 2
0
def test_cache(monkeypatch):
    """Test cache load and clear method"""

    monkeypatch.setattr(Cache, 'download', lambda _: True)

    cache_test = yaml_cache.load_test_cache()
    cache_test.dump_shelve(TEST_DUMP_FILE)

    cache = Cache(TEST_DUMP_FILE)
    assert len(cache.arch2id) == 3
    assert len(cache.arch_compat) == 2
    assert len(cache.cve_detail) == 1
    assert len(cache.dbchange) == 5
    assert len(cache.errata_detail) == 5
    assert len(cache.errataid2name) == 5
    assert len(cache.errataid2repoids) == 3
    assert len(cache.evr2id) == 7
    assert len(cache.id2arch) == 3
    assert len(cache.id2evr) == 7
    assert len(cache.id2packagename) == 3
    assert len(cache.modulename2id) == 2
    assert len(cache.nevra2pkgid) == 5
    assert len(cache.package_details) == 8
    assert len(cache.packagename2id) == 3
    assert len(cache.pkgerrata2module) == 5
    assert len(cache.pkgid2errataids) == 7
    assert len(cache.pkgid2repoids) == 6
    assert len(cache.productid2repoids) == 1
    assert len(cache.repo_detail) == 6
    assert len(cache.repolabel2ids) == 2
    assert len(cache.src_pkg_id2pkg_ids) == 2
    assert len(cache.updates) == 2
    assert len(cache.updates_index) == 2
    assert len(cache.content_set_id2label) == 3
    assert len(cache.label2content_set_id) == 3
    assert len(cache.content_set_id2pkg_name_ids) == 3

    cache.clear()
    variables = vars(cache)
    assert len(variables) == 33
    for name, var in variables.items():
        if name == "filename":
            assert var == TEST_DUMP_FILE
        else:
            assert var == {}
Esempio n. 3
0
def load_data_once():
    """Load test data only once for whole test case."""
    return yaml_cache.load_test_cache()
Esempio n. 4
0
async def server(aiohttp_server):
    """Setup testing app."""
    app = create_app()
    BaseHandler.db_cache = yaml_cache.load_test_cache()
    load_cache_to_apis()
    return await aiohttp_server(app.app)
Esempio n. 5
0
 def get_app(self):
     """Setup testing app."""
     app.BaseHandler.db_cache = yaml_cache.load_test_cache()
     app.load_cache_to_apis()
     return app.Application()