From 01b15786a8ae02d364ff79011473bde90eb42e76 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sun, 4 Aug 2019 11:54:08 +0200 Subject: Add some tests --- tests/utils/templates/test_templates.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/utils/templates/test_templates.py (limited to 'tests/utils/templates') diff --git a/tests/utils/templates/test_templates.py b/tests/utils/templates/test_templates.py new file mode 100644 index 0000000..66c77f6 --- /dev/null +++ b/tests/utils/templates/test_templates.py @@ -0,0 +1,33 @@ +import pytest +import os + +from datetime import datetime + +import resumejson_converter + +from resumejson_converter.utils import templates + + +def test_td_format_no_argument(): + with pytest.raises(TypeError): + templates.td_format() + + +def test_td_format_classic(): + startDateTime = datetime.strptime( + "2015-02-20 10:15:20", + '%Y-%m-%d %H:%M:%S') + endDateTime = datetime.strptime( + "2019-03-25 11:16:25", + '%Y-%m-%d %H:%M:%S') + diffDate = endDateTime - startDateTime + + assert templates.td_format(diffDate) == "4 ans, 1 mois, 4 jours, 1 heure, 1 minute, 5 secondes" + + +def test_td_format_week(): + startDateTime = datetime.strptime("2019-02-01", '%Y-%m-%d') + endDateTime = datetime.strptime("2019-02-16", '%Y-%m-%d') + diffDate = endDateTime - startDateTime + + assert templates.td_format(diffDate) == "2 semaines, 24 heures" -- cgit v1.2.1