From da5a71a533a157ee5b5e4bc5217493312d4f0d94 Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Tue, 6 Feb 2024 13:36:23 +0545 Subject: [PATCH] feat: unit tests added --- tests/__init__.py | 0 tests/test_date_converter.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_date_converter.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_date_converter.py b/tests/test_date_converter.py new file mode 100644 index 0000000..c832aa6 --- /dev/null +++ b/tests/test_date_converter.py @@ -0,0 +1,26 @@ +import sys +import unittest +from os.path import dirname, join, abspath + +sys.path.insert(0, abspath(join(dirname(__file__), '..'))) + +from nepali_date_utils.date_converter import converter + +class TestDateConverter(unittest.TestCase): + + # Test data sets + test_data = [ + {"bs_date": "2054/04/1", "ad_date": "1997/07/16"}, + {"bs_date": "2055/09/15", "ad_date": "1998/12/30"}, + {"bs_date": "2077/04/20", "ad_date": "2020/08/04"}, + ] + + def test_bs_to_ad(self): + for data in self.test_data: + bs_date = data["bs_date"] + expected_ad_date = data["ad_date"] + actual_ad_date = converter.bs_to_ad(bs_date) + self.assertEqual(actual_ad_date, expected_ad_date) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file