Example #1
0
def test_rights_have_valid_spdx_identifier(mock_get):
    check = RightsHaveValidSPDXIdentifierCheck()
    assert base_init_check_test(check, 13)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0]

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
    assert check.get_last_result(rdp.pid).msg == "No rights objects found!"

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome[0]
    assert not check.get_last_result(rdp.pid).outcome[1]
    assert not check.get_last_result(rdp.pid).outcome[2]
    assert check.get_last_result(
        rdp.pid
    ).msg == "Idonotexistasarightsidentifier is not a valid SPDX identifier"
Example #2
0
def test_creators_orcid_check(mock_get):
    check = CreatorsOrcidCheck()
    assert base_init_check_test(check, 19)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0]
    assert check.get_last_result(rdp.pid).outcome[1]

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome[0]

    rdp = RdpFactory.create("10.5281/zenodo.badex3", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome[0]
    assert not check.get_last_result(rdp.pid).outcome[1]

    rdp = RdpFactory.create("10.5281/zenodo.badex4", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0]
Example #3
0
def test_formats_are_valid_media_types(mock_get):
    check = FormatsAreValidMediaTypeCheck()
    assert base_init_check_test(check, 12)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0]
    assert check.get_last_result(rdp.pid).outcome[1]

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
    assert check.get_last_result(rdp.pid).msg == "No formats found!"

    rdp = RdpFactory.create("10.5281/zenodo.badex4", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0]
    assert not check.get_last_result(rdp.pid).outcome[1]

    rdp = RdpFactory.create("10.5281/zenodo.badex5", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome[0]
    assert not check.get_last_result(rdp.pid).outcome[1]
Example #4
0
def test_related_resource_metadata_check(mock_get):
    check = RelatedResourceMetadataCheck()
    assert base_init_check_test(check, 36)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert check.get_last_result(rdp.pid).outcome[0]
    assert check.get_last_result(rdp.pid).outcome[1]

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
    assert check.get_last_result(
        rdp.pid).msg == "No related resources retrievable"

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 3
    assert check.get_last_result(rdp.pid).outcome[0]
    assert not check.get_last_result(rdp.pid).outcome[1]
    assert check.get_last_result(rdp.pid).outcome[2]
Example #5
0
def test_dates_information_check(mock_get):
    check = DatesInformationCheck()
    assert base_init_check_test(check, 34)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert check.get_last_result(rdp.pid).outcome[0] is None
    assert check.get_last_result(rdp.pid).outcome[1] is None

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).msg == "No dates retrievable"

    rdp = RdpFactory.create("10.5281/zenodo.badex3", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0] == "First revision"
    assert check.get_last_result(rdp.pid).outcome[1] == "Second revision"

    rdp = RdpFactory.create("10.5281/zenodo.badex4", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0] is None
    assert check.get_last_result(rdp.pid).outcome[1] is None
Example #6
0
def test_descriptions_language_check(mock_get):
    check = DescriptionsLanguageCheck()
    assert base_init_check_test(check, 4)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert check.get_last_result(rdp.pid).outcome[0] == "en"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0] == "de"

    rdp = RdpFactory.create("10.5281/zenodo.badex5", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[2] is None

    rdp = RdpFactory.create("10.5281/zenodo.badex5", "zenodo")
    check.check(rdp)
Example #7
0
def test_rdp_zenodo_creators(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert len(rdp.metadata.creators) == 2
    assert rdp.metadata.creators[0].name == "Weber, Tobias"
    assert rdp.metadata.creators[0].givenName == "Tobias"
    assert rdp.metadata.creators[0].familyName == "Weber"
    assert rdp.metadata.creators[0].affiliations[
        0] == "Leibniz Supercomputing Centre"
    assert rdp.metadata.creators[0].orcid == "0000-0003-1815-7041"
    assert rdp.metadata.creators[1].givenName == "Nelson"
    assert rdp.metadata.creators[1].familyName == "Tavares de Sousa"
    assert rdp.metadata.creators[1].affiliations[
        0] == "Software Engineering Group, Kiel University (Germany)"
    assert rdp.metadata.creators[1].orcid == "0000-0003-1866-7156"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert len(rdp.metadata.creators) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    assert rdp.metadata.creators[0].name == "Tobias Weber"
    assert rdp.metadata.creators[0].givenName is None
    assert rdp.metadata.creators[0].familyName is None
    assert rdp.metadata.creators[0].orcid is None

    rdp = RdpFactory.create("10.5281/zenodo.badex3", "zenodo")
    assert rdp.metadata.creators[1].name == "Leibniz Rechenzentrum"
Example #8
0
def test_rdp_related_resources(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert len(rdp.metadata.relatedResources) == 2
    assert rdp.metadata.relatedResources[0].pid == "10.5281/zenodo.3490329"
    assert rdp.metadata.relatedResources[0].pidType == "DOI"
    assert rdp.metadata.relatedResources[0].relationType == "IsSourceOf"
    assert rdp.metadata.relatedResources[1].pid == "10.5281/zenodo.3490395"
    assert rdp.metadata.relatedResources[1].pidType == "DOI"
    assert rdp.metadata.relatedResources[1].relationType == "IsVersionOf"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert len(rdp.metadata.relatedResources) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    assert len(rdp.metadata.relatedResources) == 3
    assert rdp.metadata.relatedResources[0].pid == "10.5281/zenodo.3490329"
    assert rdp.metadata.relatedResources[0].pidType == "DOI"
    assert rdp.metadata.relatedResources[0].relationType == "Cites"
    assert rdp.metadata.relatedResources[1].pid == "10.5281/zenodo.3490395"
    assert rdp.metadata.relatedResources[1].pidType == "DOI"
    assert rdp.metadata.relatedResources[1].relationType == "HasMetadata"
    assert rdp.metadata.relatedResources[1].schemeURI is None
    assert rdp.metadata.relatedResources[1].schemeType is None
    assert rdp.metadata.relatedResources[2].pid == "10.5281/zenodo.3490396"
    assert rdp.metadata.relatedResources[2].pidType == "DOI"
    assert rdp.metadata.relatedResources[2].relationType == "HasMetadata"
    assert rdp.metadata.relatedResources[
        2].schemeURI == "http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd"
    assert rdp.metadata.relatedResources[2].schemeType == "XSD"

    rdp = RdpFactory.create("10.5281/zenodo.badex5", "zenodo")
    assert len(rdp.metadata.relatedResources) == 1
Example #9
0
def test_doi_resolve_check(mock_head, mock_get):
    check = DoiResolvesCheck()
    assert base_init_check_test(check, 1)

    # Successful resolution
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome

    # failure
    rdp.pid = ""
    check.check(rdp)
    assert not check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome

    # Failed resolution
    rdp = RdpFactory.create("10.123/zenodo.3490396-failure", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome

    # Exception
    rdp = RdpFactory.create("10.123/zenodo.3490396-exception", "zenodo")
    check.check(rdp)
    assert not check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(
        rdp.pid).msg == "Exception: Something went terribly wrong"
Example #10
0
def test_rights_has_at_least_one_license(mock_get, mock_head):
    check = RightsHasAtLeastOneLicenseCheck()
    assert base_init_check_test(check, 14)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.log.get_by_pid(rdp.pid)[-1].result.outcome
    assert check.get_last_result(rdp.pid).outcome

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome
    assert check.get_last_result(rdp.pid).msg == "No rights specified"

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome
    assert check.get_last_result(
        rdp.pid).msg.startswith("No license retrievable:")

    rdp = RdpFactory.create("10.5281/zenodo.badex4", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert not check.get_last_result(rdp.pid).outcome
    assert check.get_last_result(
        rdp.pid).msg.startswith("No license retrievable:")
Example #11
0
def test_contributors_type_check(mock_get):
    check = ContributorsTypeCheck()
    assert base_init_check_test(check, 29)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert check.get_last_result(rdp.pid).outcome[0] == "ContactPerson"
    assert check.get_last_result(rdp.pid).outcome[1] == "ProjectMember"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 1
    assert check.get_last_result(rdp.pid).outcome[0] == "Editor"

    rdp = RdpFactory.create("10.5281/zenodo.badex3", "zenodo")
    check.check(rdp)
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0] == "RightsHolder"
    assert check.get_last_result(rdp.pid).outcome[1] == "HostingInstitution"
Example #12
0
def test_rdp_zenodo_language(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert rdp.metadata.language == "en"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert rdp.metadata.language is None

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    assert rdp.metadata.language == "English"
Example #13
0
def test_benchmark(mock_get, mock_head):
    b = Benchmark()
    c1 = DescriptionsNumberCheck()
    rdp1 = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    rdp2 = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    c1.check(rdp1)
    c1.check(rdp2)
    b.add_evaluation(IsBetweenEvaluation([c1], 1, 100))
    assert len(b.evaluations) == 1
    assert b.score(rdp1) == 1
    assert b.score(rdp2) == 0
Example #14
0
def test_rdp_zenodo_size(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert rdp.metadata.sizes[0] == "12000kb"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert len(rdp.metadata.sizes) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    assert len(rdp.metadata.sizes) == 2
    assert rdp.metadata.sizes[0] == "120 records"
    assert rdp.metadata.sizes[1] == "12 GB"
Example #15
0
def test_rdp_zenodo_description(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert len(rdp.metadata.descriptions) > 0
    assert len(rdp.metadata.descriptions[0].text) > 15
    assert rdp.metadata.descriptions[0].type == "Abstract"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert len(rdp.metadata.descriptions) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex4", "zenodo")
    assert len(rdp.metadata.descriptions) == 1
Example #16
0
def test_rdp_type(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert rdp.metadata.type == "Dataset"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert rdp.metadata.type is None

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    assert rdp.metadata.type == "Text"

    rdp = RdpFactory.create("10.5281/zenodo.badex3", "zenodo")
    assert rdp.metadata.type == "Text"
Example #17
0
def test_descriptions_number_check(mock_get):
    check = DescriptionsNumberCheck()
    assert base_init_check_test(check, 2)
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome == 2

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome == 0
Example #18
0
def test_benchmark(mock_get, mock_head):
    b = Benchmark()
    c1 = DescriptionsNumberCheck()
    b.add_evaluation(IsBetweenEvaluation([c1], 1, 100))
    rdp = RdpFactory.create("10.5281/zenodo.exception1", "zenodo")
    with pytest.raises(CannotCreateRDPException) as e:
        b.check_all(rdp)
        str(e).endswith("404")
    rdp = RdpFactory.create("10.5281/zenodo.exception2", "zenodo")
    with pytest.raises(CannotCreateRDPException) as e:
        b.check_all(rdp)
        str(e).endswith("429")
Example #19
0
def test_rdp_zenodo_formats(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert len(rdp.metadata.formats) == 2
    assert rdp.metadata.formats[0] == "application/json"
    assert rdp.metadata.formats[1] == "text/csv"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert len(rdp.metadata.formats) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    assert len(rdp.metadata.formats) == 1
    assert rdp.metadata.formats[0] == "application/json"
Example #20
0
def get_rdps():
    return [
        RdpFactory.create("10.5281/zenodo.3490396", "zenodo"),
        RdpFactory.create("10.123/zenodo.badex1", "zenodo"),
        RdpFactory.create("10.123/zenodo.badex2", "zenodo"),
        RdpFactory.create("10.123/zenodo.badex3", "zenodo"),
        RdpFactory.create("10.123/zenodo.badex4", "zenodo"),
        RdpFactory.create("10.123/zenodo.badex5", "zenodo"),
        RdpFactory.create("10.123/zenodo.goodex1", "zenodo"),
        RdpFactory.create("10.123/zenodo.goodex2", "zenodo"),
        RdpFactory.create("10.123/zenodo.goodex3", "zenodo"),
        RdpFactory.create("10.123/zenodo.goodex4", "zenodo")
    ]
Example #21
0
def test_publicationYear_check(mock_get):
    check = PublicationYearCheck()
    assert base_init_check_test(check, 31)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome == 2019

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert not check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(
        rdp.pid).msg == "No publicationYear retrievable"
Example #22
0
def test_descriptions_length_check(mock_get):
    check = DescriptionsLengthCheck()
    assert base_init_check_test(check, 3)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0] == 69
    assert check.get_last_result(rdp.pid).outcome[1] == 3

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
Example #23
0
def test_descriptions_types_check(mock_get):
    check = DescriptionsTypeCheck()
    assert base_init_check_test(check, 5)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert "Abstract" in check.get_last_result(rdp.pid).outcome

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
Example #24
0
def test_contributors_family_and_given_name_check(mock_get):
    check = ContributorsFamilyAndGivenNameCheck()
    assert base_init_check_test(check, 27)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0]
    assert check.get_last_result(rdp.pid).outcome[1]

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
Example #25
0
def test_titles_type_check(mock_get):
    check = TitlesTypeCheck()
    assert base_init_check_test(check, 10)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    check.get_last_result(rdp.pid).outcome[0] is None
    check.get_last_result(rdp.pid).outcome[1] == "TranslatedTitle"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
Example #26
0
def test_titles_just_a_filename_check(mock_get):
    check = TitlesJustAFileNameCheck()
    assert base_init_check_test(check, 9)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    for o in check.get_last_result(rdp.pid).outcome:
        assert not o

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert check.get_last_result(rdp.pid).outcome[0]
Example #27
0
def test_titles_language_check(mock_get):
    check = TitlesLanguageCheck()
    assert base_init_check_test(check, 8)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert check.get_last_result(rdp.pid).outcome[0] == "en"
    assert check.get_last_result(rdp.pid).outcome[1] == "de"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
Example #28
0
def test_related_resource_type_check(mock_get):
    check = RelatedResourceTypeCheck()
    assert base_init_check_test(check, 35)

    # Successful check
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 2
    assert check.get_last_result(rdp.pid).outcome[0] == "IsSourceOf"
    assert check.get_last_result(rdp.pid).outcome[1] == "IsVersionOf"

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    check.check(rdp)
    assert check.log.get_by_pid(rdp.pid)[-1].result.success
    assert len(check.get_last_result(rdp.pid).outcome) == 0
    assert check.get_last_result(
        rdp.pid).msg == "No related resources retrievable"
Example #29
0
def test_rdp_zenodo_dates(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert len(rdp.metadata.dates) == 2
    assert rdp.metadata.dates[0].type == "Issued"
    assert rdp.metadata.dates[0].date.year == 2019
    assert rdp.metadata.dates[0].date.month == 10
    assert rdp.metadata.dates[0].date.day == 15
    assert rdp.metadata.dates[0].end.year == rdp.metadata.dates[0].date.year
    assert rdp.metadata.dates[0].end.month == rdp.metadata.dates[0].date.month
    assert rdp.metadata.dates[0].end.day == rdp.metadata.dates[0].date.day
    assert rdp.metadata.dates[0].information is None
    assert not rdp.metadata.dates[0].duration
    assert rdp.metadata.dates[1].type == "Created"
    assert rdp.metadata.dates[1].date.year == 2019
    assert rdp.metadata.dates[1].date.month == 3
    assert rdp.metadata.dates[1].date.day == 1
    assert rdp.metadata.dates[1].end.day == 4
    assert rdp.metadata.dates[1].end.hour == 14
    assert rdp.metadata.dates[1].end.second == 13
    assert rdp.metadata.dates[1].duration
    assert rdp.metadata.dates[1].information is None

    rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo")
    assert len(rdp.metadata.dates) == 0

    rdp = RdpFactory.create("10.5281/zenodo.badex2", "zenodo")
    assert len(rdp.metadata.dates) == 1
    assert rdp.metadata.dates[0].type == None
    assert rdp.metadata.dates[0].date.year == 2019
    assert rdp.metadata.dates[0].date.month == 10
    assert rdp.metadata.dates[0].date.day == 15
    assert rdp.metadata.dates[0].information is None

    rdp = RdpFactory.create("10.5281/zenodo.badex3", "zenodo")
    assert rdp.metadata.dates[0].type == "Updated"
    assert rdp.metadata.dates[0].information == "First revision"
    assert rdp.metadata.dates[1].type == "Updated"
    assert rdp.metadata.dates[1].information == "Second revision"

    rdp = RdpFactory.create("10.5281/zenodo.badex4", "zenodo")
    assert rdp.metadata.dates[0].type == "Updated"
    assert rdp.metadata.dates[0].information is None
    assert rdp.metadata.dates[1].type == "Updated"
    assert rdp.metadata.dates[1].information is None
Example #30
0
def test_rdp_zenodo_services(mock_get):
    rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo")
    assert len(rdp.services) == 2
    services = ["oai-pmh", "zenodo-rest-api"]
    for idx, service_name in enumerate(rdp.services):
        if idx == 0:
            assert service_name in services
            services.remove(service_name)
        if idx == 1:
            assert service_name == services[0]