From 148c95b1382d9bbc9c129d3211009d13b1a493aa Mon Sep 17 00:00:00 2001 From: jonavellecuerdo Date: Fri, 9 Aug 2024 10:49:57 -0400 Subject: [PATCH] add dedupe tests for dates and locations --- tests/test_models.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/test_models.py b/tests/test_models.py index ec2600c..e260268 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -7,6 +7,7 @@ DateRange, Identifier, Link, + Location, Note, Subject, ) @@ -374,3 +375,36 @@ def test_timdex_record_not_a_list_raises_error(timdex_record_required_fields): match="'dates' must be ", ): timdex_record_required_fields.dates = "test" + + +def test_timdex_record_dedupe_locations(timdex_record_required_fields): + timdex_record_required_fields.locations = [ + Location(value="One Place", kind="Place of Publication"), + Location(value="One Place", kind="Place of Publication"), + Location(value="Another Place", kind="Place of Publication"), + ] + assert set(timdex_record_required_fields.locations) == { + Location(value="One Place", kind="Place of Publication"), + Location(value="Another Place", kind="Place of Publication"), + } + + +def test_timdex_record_dedupe_dates(timdex_record_required_fields): + timdex_record_required_fields.dates = [ + Date(value="Date with no kind"), + Date(value="Date with no kind"), + Date(value="2022-01-01", kind="Publication date"), + Date( + range=DateRange(gt="2019-01-01", lt="2019-06-30"), + ), + Date( + range=DateRange(gt="2019-01-01", lt="2019-06-30"), + ), + ] + assert set(timdex_record_required_fields.dates) == { + Date(value="Date with no kind"), + Date(value="2022-01-01", kind="Publication date"), + Date( + range=DateRange(gt="2019-01-01", lt="2019-06-30"), + ), + }