diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2020-11-14 03:51:25 +0100 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2020-11-14 03:51:25 +0100 |
commit | b5460fe884582cd7c7e6cc4f5b6cd2f1f0af1f86 (patch) | |
tree | 205f326b0d85c2cf6180b9802e1f119a9e5dfd90 /tests | |
parent | 89b9da699446c9a7566b3a9a444221fe4982058a (diff) | |
download | fuzzycat-b5460fe884582cd7c7e6cc4f5b6cd2f1f0af1f86.tar.gz fuzzycat-b5460fe884582cd7c7e6cc4f5b6cd2f1f0af1f86.zip |
wip: verification and tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_verify.py | 31 | ||||
-rw-r--r-- | tests/test_verify/0000.yml | 104 |
2 files changed, 135 insertions, 0 deletions
diff --git a/tests/test_verify.py b/tests/test_verify.py new file mode 100644 index 0000000..be4b0ec --- /dev/null +++ b/tests/test_verify.py @@ -0,0 +1,31 @@ +import operator +import os +import yaml +try: + from yaml import CLoader as Loader +except ImportError: + from yaml import Loader + +from fuzzycat.verify import compare, Status + + +def test_verify_cases(): + """ + Test verification cases, via yaml. + """ + status_map = { + "AMBIGUOUS": Status.AMBIGUOUS, + "DIFFERENT": Status.DIFFERENT, + "EXACT": Status.EXACT, + "STRONG": Status.STRONG, + "WEAK": Status.WEAK, + } + fields = operator.itemgetter("a", "b", "status", "about") + folder = os.path.join(os.path.dirname(__file__), "test_verify") + for root, _, files in os.walk(folder): + for fn in files: + with open(os.path.join(root, fn)) as f: + doc = yaml.load(f, Loader=Loader) + a, b, status, about = fields(doc) + result, _ = compare(a, b) + assert status_map.get(status) == result, about diff --git a/tests/test_verify/0000.yml b/tests/test_verify/0000.yml new file mode 100644 index 0000000..a82b2fe --- /dev/null +++ b/tests/test_verify/0000.yml @@ -0,0 +1,104 @@ +about: Same document should be an exact match. +status: EXACT +a: + abstracts: + - content: Belgium Herbarium image of Meise Botanic Garden. + lang: de + mimetype: text/plain + sha1: cd3c76f5fd94bcf260f9ad74f797d9e79a824b1d + contribs: + - index: 0 + raw_name: Meise Botanic Garden + role: author + ext_ids: + doi: 10.5281/zenodo.2830437 + extra: + datacite: + license: + - rights: Creative Commons Attribution Share Alike 4.0 International + rightsUri: http://creativecommons.org/licenses/by-sa/4.0/legalcode + - rights: Open Access + rightsUri: info:eu-repo/semantics/openAccess + relations: + - relatedIdentifier: 10.5281/zenodo.2830436 + relatedIdentifierType: DOI + relationType: IsVersionOf + - relatedIdentifier: https://zenodo.org/communities/belgiumherbarium + relatedIdentifierType: URL + relationType: IsPartOf + resourceType: Photo + resourceTypeGeneral: Image + subjects: + - subject: Biodiversity + - subject: Taxonomy + - subject: Terrestrial + - subject: Herbarium + - subject: Caryophyllaceae + release_month: 5 + files: [] + filesets: [] + ident: jihezebuzbgxpmsj3356idy52e + license_slug: CC-BY-SA + publisher: Zenodo + refs: [] + release_date: "2019-05-14" + release_stage: published + release_type: graphic + release_year: 2019 + revision: 560ca270-45c5-4f21-89a6-0dfd73039546 + state: active + title: Dianthus carthusianorum L. (BR0000005352692) + webcaptures: [] + work_id: aaaaa34uyngfplcgmoejzjyjne +b: + abstracts: + - content: Belgium Herbarium image of Meise Botanic Garden. + lang: de + mimetype: text/plain + sha1: cd3c76f5fd94bcf260f9ad74f797d9e79a824b1d + contribs: + - index: 0 + raw_name: Meise Botanic Garden + role: author + ext_ids: + doi: 10.5281/zenodo.2830437 + extra: + datacite: + license: + - rights: Creative Commons Attribution Share Alike 4.0 International + rightsUri: http://creativecommons.org/licenses/by-sa/4.0/legalcode + - rights: Open Access + rightsUri: info:eu-repo/semantics/openAccess + relations: + - relatedIdentifier: 10.5281/zenodo.2830436 + relatedIdentifierType: DOI + relationType: IsVersionOf + - relatedIdentifier: https://zenodo.org/communities/belgiumherbarium + relatedIdentifierType: URL + relationType: IsPartOf + resourceType: Photo + resourceTypeGeneral: Image + subjects: + - subject: Biodiversity + - subject: Taxonomy + - subject: Terrestrial + - subject: Herbarium + - subject: Caryophyllaceae + release_month: 5 + files: [] + filesets: [] + ident: jihezebuzbgxpmsj3356idy52e + license_slug: CC-BY-SA + publisher: Zenodo + refs: [] + release_date: "2019-05-14" + release_stage: published + release_type: graphic + release_year: 2019 + revision: 560ca270-45c5-4f21-89a6-0dfd73039546 + state: active + title: Dianthus carthusianorum L. (BR0000005352692) + webcaptures: [] + work_id: aaaaa34uyngfplcgmoejzjyjne + + |