From c727d56ed050b3c1ea3331a5a7e3e1b0ae295f77 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 31 May 2017 18:05:04 +0100 Subject: [PATCH] Add unit tests for empty dates --- gramps/gen/lib/test/date_test.py | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gramps/gen/lib/test/date_test.py b/gramps/gen/lib/test/date_test.py index c6a6611e1..d4312637b 100644 --- a/gramps/gen/lib/test/date_test.py +++ b/gramps/gen/lib/test/date_test.py @@ -536,5 +536,42 @@ class Test_set_newyear(BaseDateTest): except DateError: self.assertTrue(should_raise, message) +#------------------------------------------------------------------------- +# +# EmptyDateTest +# +#------------------------------------------------------------------------- +class EmptyDateTest(BaseDateTest): + """ + Tests for empty dates. + """ + def test_empty(self): + d = Date() + self.assertTrue(d.is_empty()) + + def test_text_only_empty(self): + d = Date() + d.set(text='First of Jan', + modifier=Date.MOD_TEXTONLY) + self.assertFalse(d.is_empty()) + + def test_single_empty(self): + d = Date() + d.set(value=(1, 1, 1900, False), + modifier=Date.MOD_NONE) + self.assertFalse(d.is_empty()) + + def test_range_empty(self): + d = Date() + d.set(value=(1, 1, 1900, False, 1, 1, 1910, False), + modifier=Date.MOD_RANGE) + self.assertFalse(d.is_empty()) + + def test_span_empty(self): + d = Date() + d.set(value=(1, 1, 1900, False, 1, 1, 1910, False), + modifier=Date.MOD_SPAN) + self.assertFalse(d.is_empty()) + if __name__ == "__main__": unittest.main()