[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.
- [gnunet-python] branch master updated (bda184f -> a3707a2), gnunet, 2020/04/12
- [gnunet-python] 01/12: Add a small test-suite., gnunet, 2020/04/12
- [gnunet-python] 04/12: Avoid "During handling of the above exception" when re-raising., gnunet, 2020/04/12
- [gnunet-python] 02/12: Extend .gitignore., gnunet, 2020/04/12
- [gnunet-python] 03/12: Simplify initiation of `_Key` and subclasses., gnunet, 2020/04/12
- [gnunet-python] 07/12: Add test-cases for strings.string_to_absolute_time.,
gnunet <=
- [gnunet-python] 06/12: Use relative imports., gnunet, 2020/04/12
- [gnunet-python] 05/12: Add '_Key.__repr__()' to eliminate redundant code in subclasses., gnunet, 2020/04/12
- [gnunet-python] 08/12: Replace spaghetti code by loops., gnunet, 2020/04/12
- [gnunet-python] 09/12: Add test-cases for strings.data_to_string and string_to_data., gnunet, 2020/04/12
- [gnunet-python] 10/12: Mark strings.encTable as private., gnunet, 2020/04/12
- [gnunet-python] 11/12: Use upper-case names for global constant values., gnunet, 2020/04/12
- [gnunet-python] 12/12: Break some very long lines and some other minor code-cleanup., gnunet, 2020/04/12