gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-python] 07/12: Add test-cases for strings.string_to_absolute_tim


From: gnunet
Subject: [gnunet-python] 07/12: Add test-cases for strings.string_to_absolute_time.
Date: Sun, 12 Apr 2020 23:22:25 +0200

This is an automated email from the git hooks/post-receive script.

htgoebel pushed a commit to branch master
in repository gnunet-python.

commit a755de67aece9b1d1e4564fb5fd3eeed5cc542fa
Author: Hartmut Goebel <address@hidden>
AuthorDate: Sat Jan 19 21:24:22 2019 +0100

    Add test-cases for strings.string_to_absolute_time.
---
 tests/unit/test_strings.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tests/unit/test_strings.py b/tests/unit/test_strings.py
new file mode 100644
index 0000000..a0b5617
--- /dev/null
+++ b/tests/unit/test_strings.py
@@ -0,0 +1,32 @@
+import pytest
+
+from gnunet import strings
+
+import locale
+locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
+
+test_dates = (
+    ("Sat Jan 07 19:54:12 2008", (2008, 1, 7, 19, 54, 12)),
+    ("Thu 27 Mar 2005 11:05:25 PM CET", (2005, 3, 27, 23, 5, 25)),
+    # FIXME: need test-case for %Ec
+    ("2019-02-23 16:07:22", (2019, 2, 23, 16, 7, 22)),
+    ("1998-08-17 14:33", (1998, 8, 17, 14, 33, 0)),
+    ("12/15/2007", (2007, 12, 15, 0, 0, 0)),
+    # FIXME: need test-case for %Ex
+    ("2019-02-26", (2019, 2, 26, 0, 0, 0)),
+    ("2014-03-23", (2014, 3, 23, 0, 0, 0)),
+    ("2020", (2020, 1, 1, 0, 0, 0))
+    )
+
+@pytest.mark.parametrize("datestr,expected", test_dates)
+def test_string_to_absolute_time(datestr, expected):
+    dt = strings.string_to_absolute_time(datestr)
+    assert dt.timetuple()[:6] == expected
+
+def test_string_to_absolute_time_end_of_time():
+    assert strings.string_to_absolute_time("end of time") is None
+
+def test_string_to_absolute_invalid():
+    with pytest.raises(ValueError) as excinfo:
+        strings.string_to_absolute_time("asdfgh")
+    assert str(excinfo.value).startswith("asdfgh is not a properly formatted")

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]