gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-python] 09/12: Add test-cases for strings.data_to_string and str


From: gnunet
Subject: [gnunet-python] 09/12: Add test-cases for strings.data_to_string and string_to_data.
Date: Sun, 12 Apr 2020 23:22:27 +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 7bff5380fb22fa27eecd09d3a2e37d9fc085246c
Author: Hartmut Goebel <address@hidden>
AuthorDate: Sat Jan 19 21:50:07 2019 +0100

    Add test-cases for strings.data_to_string and string_to_data.
---
 tests/unit/test_strings.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tests/unit/test_strings.py b/tests/unit/test_strings.py
index a0b5617..835a508 100644
--- a/tests/unit/test_strings.py
+++ b/tests/unit/test_strings.py
@@ -23,10 +23,28 @@ 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")
+
+
+def test_data_to_string():
+    assert strings.data_to_string(b"") == ""
+    assert strings.data_to_string(b"dfgzu") == "CHJ6EUJL"
+
+
+def test_string_to_data():
+    assert strings.string_to_data("") == b""
+    assert strings.string_to_data("CHJ6EUJL") == b"dfgzu"
+    with pytest.raises(ValueError) as excinfo:
+        strings.string_to_data("asdfgh")
+    assert "is not a valid data-encoding string" in str(excinfo.value)
+    with pytest.raises(ValueError) as excinfo:
+        strings.string_to_data(["asdfgh"])
+    assert "is not a valid data-encoding string" in str(excinfo.value)

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



reply via email to

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