Пример #1
0
def test_load_prov_files(prov_files, test_filenames):
    assert provit.prov.load_prov_files(prov_files) == []
    prov = Provenance(prov_files / test_filenames["TEST_FILE"])
    prov.add(agents=["yada"], activity="testing", description="this is a testfunction")
    prov.save()
    loaded_prov = provit.prov.load_prov_files(prov_files)[0]
    assert loaded_prov.file_name == prov.file_name
Пример #2
0
def test_add_incorrect_source_file(prov_files, test_filenames):
    """
    Test adding a incorrect file as source
    """

    prov = Provenance(prov_files / test_filenames["TEST_FILE"])
    prov.add(agents=["yada"], activity="testing", description="this is a testfunction")
    with pytest.raises(IOError):
        prov.add_sources([prov_files / test_filenames["NO_FILE"]])
Пример #3
0
def test_get_current_location(prov_files, test_filenames, prov_path_with_agents):
    provit.prov.cfg = get_config(prov_path_with_agents)
    prov = provit.prov.Provenance(prov_files / test_filenames["TEST_FILE"])
    prov.add(
        agents=["wikidata"], activity="testing", description="this is a testfunction"
    )
    assert str(prov.get_current_location()) == str(
        prov_files / test_filenames["TEST_FILE"]
    )
Пример #4
0
def test_add_source_prov(prov_files, test_filenames):
    """
    Test if created prov information for prov source file (with no
    prior prov file) is correct
    """

    prov = Provenance(prov_files / test_filenames["TEST_FILE"])
    prov.add(agents=["yada"], activity="testing", description="this is a testfunction")
    prov.add_sources([prov_files / test_filenames["SOURCE_FILE"]])
    prov.save()

    assert len(prov.tree()["sources"]) == 1
    assert (
        prov.tree()["sources"][0]["agent"][0]
        == "http://vocab.ub.uni-leipzig.de/provit/provit"
    )
    assert "initialize_provit" in prov.tree()["sources"][0]["activity"]
Пример #5
0
def test_get_agents(prov_files, test_filenames, prov_path_with_agents):
    provit.prov.cfg = get_config(prov_path_with_agents)
    prov = provit.prov.Provenance(prov_files / test_filenames["TEST_FILE"])
    prov.add(
        agents=["wikidata"], activity="testing", description="this is a testfunction"
    )
    prov.add(
        agents=["gephi_0.9.2"], activity="testing", description="this is a testfunction"
    )
    prov.add(
        agents=["johndoe"], activity="testing", description="this is a testfunction"
    )
    agent_list = prov.get_agents()
    assert len(agent_list) == 3
    assert prov.get_agents(include_primary_sources=True)["wikidata"] == {
        "slug": "wikidata",
        "uri": "http://vocab.ub.uni-leipzig.de/provit/wikidata",
        "type": "Organization",
        "name": ["Wikidata"],
        "homepage": ["https://www.wikidata.org"],
    }
Пример #6
0
def test_add_same_source_prov(prov_files, test_filenames):
    prov = Provenance(prov_files / test_filenames["TEST_FILE"])
    prov.add(agents=["yada"], activity="testing", description="this is a testfunction")
    prov.add_sources([prov_files / test_filenames["TEST_FILE"]])
    assert prov.tree()["sources"] == []