def test_subjects_have_ddc_check(mock_get): check = SubjectsHaveDdcCheck() assert base_init_check_test(check, 17) # 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 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 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
def test_subjects_number_check(mock_get): check = SubjectsNumberCheck() assert base_init_check_test(check, 16) # 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 == 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 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 == 5
def test_contributors_contain_institutions_check(mock_get): check = ContributorsContainInstitutionsCheck() assert base_init_check_test(check, 28) # 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 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.badex1", "zenodo") check.check(rdp) assert not check.log.get_by_pid(rdp.pid)[-1].result.success 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 check.get_last_result(rdp.pid).outcome[1]
def test_contributors_orcid_check(mock_get): check = ContributorsOrcidCheck() assert base_init_check_test(check, 26) # 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.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]
def test_size_byte_check(mock_get): check = SizesByteSizeCheck() assert base_init_check_test(check, 23) # 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 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 check.get_last_result(rdp.pid).outcome[1]
def test_language_specified_check(mock_get): check = LanguageSpecifiedCheck() assert base_init_check_test(check, 25) # 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 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 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 == "'English' is not a valid ISO-639-1 code"
def test_version_specified_check(mock_get): check = VersionSpecifiedCheck() assert base_init_check_test(check, 24) # 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 rdp = RdpFactory.create("10.5281/zenodo.badex1", "zenodo") check.check(rdp) assert not check.log.get_by_pid(rdp.pid)[-1].result.success assert not check.get_last_result(rdp.pid).outcome 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 == "'34' is not in semantic versioning format"
def test_creators_family_and_given_name_check(mock_get): check = CreatorsFamilyAndGivenNameCheck() assert base_init_check_test(check, 20) # 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] assert check.get_last_result(rdp.pid).outcome[1]
def test_rights_are_open_check(mock_get): check = RightsAreOpenCheck() assert base_init_check_test(check, 30) # 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 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 assert check.get_last_result( rdp.pid).msg == "Rights are not open (or not 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
def test_dates_type_check(mock_get): check = DatesTypeCheck() assert base_init_check_test(check, 32) # 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] == "Issued" assert check.get_last_result(rdp.pid).outcome[1] == "Created" 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.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] is None
def test_subjects_are_qualified_check(mock_get): check = SubjectsAreQualifiedCheck() assert base_init_check_test(check, 15) # 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 not 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 subjects retrievable" 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 check.get_last_result(rdp.pid).outcome[4]
def test_is_valid_doi_check(mock_get): check = IsValidDoiCheck() assert base_init_check_test(check, 0) assert check.description == "Checks whether an RDP has a valid DOI as PID" rdp = RdpFactory.create("10.5281/zenodo.3490396", "zenodo") assert rdp.pid == rdp.metadata.pid check.check(rdp) assert check.log.get_by_pid(rdp.pid)[-1].result.success assert len(check.log) == 1 assert check.log.log[-1].result.success assert check.get_last_result(rdp.pid).outcome # Failure 1 pid = rdp.pid rdp.pid = "" check.check(rdp) assert not check.log.get_by_pid(rdp.pid)[-1].result.success assert len(check.log) == 2 assert check.log.log[-2].result.success assert not check.get_last_result(rdp.pid).outcome rdp.pid = pid # Failure 2 rdp = RdpFactory.create("10.123/zenodo.3490396-failure", "zenodo") check.check(rdp) assert check.log.get_by_pid(rdp.pid)[-1].result.success assert len(check.log) == 3 assert check.log.log[-3].result.success assert not check.log.log[-2].result.success assert not check.get_last_result(rdp.pid).outcome rdp = RdpFactory.create("10.123/zenodo.badex1", "zenodo") assert not rdp.pid == rdp.metadata.pid check.check(rdp) assert check.log.get_by_pid(rdp.pid)[-1].result.success assert not check.get_last_result(rdp.pid).outcome