Skip to content

Commit

Permalink
fix(match): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alhayward committed Sep 25, 2024
1 parent 8817427 commit 5a5ffb6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/unit/test_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,20 @@ def test_feature_match_four_char():


def test_feature_match_exact():
record_i = [1, 0, -1, "blah", "", True]
record_j = [1, 0, -1, "blah", "", True]
record_k = [2, 10, -10, "no match", "null", False]
record_i = ["240 Rippin Ranch Apt 66", "1980-01-01", "Los Angeles", "Verónica Eva", "Reynoso", "834d436b-9e1f-2e8e-f28a-ad40bef9f365", "female", "CA", "90502"]
record_j = ["240 Rippin Ranch Apt 66", "1980-01-01", "Los Angeles", "Verónica Eva", "Reynoso", "834d436b-9e1f-2e8e-f28a-ad40bef9f365", "female", "CA", "90502"]
record_k = ["240 Rippin Ranch Apt 66", datetime.date(1980, 1, 1), "Los Angeles", "Verónica Eva", "Reynoso", "834d436b-9e1f-2e8e-f28a-ad40bef9f365", "female", "CA", "90502"]
record_l = ["123 X St Unit 2", "1995-06-20", "Chicago", "Alejandra", "Arenas", "124d436b-9e1f-2e8e-f28a-ad40bef9f367", "male", "IL", "60615"]
record_m = ["123 X St Unit 2", datetime.date(1980, 6, 20), "Chicago", "Alejandra", "Arenas", "124d436b-9e1f-2e8e-f28a-ad40bef9f367", "male", "IL", "60615"]

cols = {"col_1": 0, "col_2": 1, "col_3": 2, "col_4": 3, "col_5": 4, "col_6": 5}
cols = {"address": 0, "birthdate": 1, "city": 2, "first_name": 3, "last_name": 4, "mrn": 5, "sex": 6, "state": 7, "zip": 8}

# Simultaneously test matches and non-matches of different data types
for c in cols:
assert matchers.feature_match_exact(record_i, record_j, c, cols)
assert not matchers.feature_match_exact(record_i, record_k, c, cols)
assert matchers.feature_match_exact(record_i, record_k, c, cols)
assert not matchers.feature_match_exact(record_i, record_l, c, cols)
assert not matchers.feature_match_exact(record_i, record_m, c, cols)

# Special case for matching None--None == None is vacuous
assert matchers.feature_match_exact([None], [None], "col_7", {"col_7": 0})
Expand Down

0 comments on commit 5a5ffb6

Please sign in to comment.