aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_verify.py
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2020-11-24 23:51:40 +0100
committerMartin Czygan <martin.czygan@gmail.com>2020-11-24 23:51:40 +0100
commit268e7948e6fa2ee9871430104f60bdab3212464c (patch)
treeb25b96f17767a4f9fdd72e73ccbb5d7b41050314 /tests/test_verify.py
parent48d9265ce97e032e4f5fd2aaa3bde7fb8f49d6c5 (diff)
downloadfuzzycat-268e7948e6fa2ee9871430104f60bdab3212464c.tar.gz
fuzzycat-268e7948e6fa2ee9871430104f60bdab3212464c.zip
move towards data subdir
Diffstat (limited to 'tests/test_verify.py')
-rw-r--r--tests/test_verify.py56
1 files changed, 29 insertions, 27 deletions
diff --git a/tests/test_verify.py b/tests/test_verify.py
index be4b0ec..889094f 100644
--- a/tests/test_verify.py
+++ b/tests/test_verify.py
@@ -1,31 +1,33 @@
-import operator
+import json
import os
-import yaml
-try:
- from yaml import CLoader as Loader
-except ImportError:
- from yaml import Loader
-
+import csv
from fuzzycat.verify import compare, Status
+VERIFY_CSV = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/verify.csv")
+RELEASE_ENTITIES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/release")
+
+status_mapping = {
+ "Status.AMBIGUOUS": Status.AMBIGUOUS,
+ "Status.DIFFERENT": Status.DIFFERENT,
+ "Status.EXACT": Status.EXACT,
+ "Status.STRONG": Status.STRONG,
+ "Status.WEAK": Status.WEAK,
+}
+
+
+def load_release_ident(ident):
+ dst = os.path.join(RELEASE_ENTITIES_DIR, ident)
+ with open(dst) as f:
+ return json.load(f)
+
-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
+def test_compare():
+ with open(VERIFY_CSV) as f:
+ reader = csv.reader(f, delimiter=',')
+ for i, row in enumerate(reader):
+ a, b, expected_status, expected_reason = row
+ status, reason = compare(load_release_ident(a), load_release_ident(b))
+ assert status == status, "status: want {}, got {} for {} {}".format(
+ expected_status, status, a, b)
+ if expected_reason:
+ assert reason == reason, "reason: want {}, got {}".format(expected_reason, reason)