[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-python] 01/12: Add a small test-suite.
From: |
gnunet |
Subject: |
[gnunet-python] 01/12: Add a small test-suite. |
Date: |
Sun, 12 Apr 2020 23:22:19 +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 4309d80e3f8be6bfcf911cf75ea691694a0dbb15
Author: Hartmut Goebel <address@hidden>
AuthorDate: Sat Jan 19 20:28:56 2019 +0100
Add a small test-suite.
---
tests/unit/test_crypto.py | 31 +++++++++++++++++++++++++++++++
tests/unit/test_hashcode.py | 32 ++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/tests/unit/test_crypto.py b/tests/unit/test_crypto.py
new file mode 100644
index 0000000..ab3db79
--- /dev/null
+++ b/tests/unit/test_crypto.py
@@ -0,0 +1,31 @@
+import pytest
+
+from gnunet.crypto import EcdsaPublicKey
+
+def test___repr__():
+ k = EcdsaPublicKey(b"abcd"*(256//8//4))
+ assert repr(k).startswith('gnunet.crypto.EcdsaPublicKey(')
+
+def test___init__string():
+ s = "C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P31C9HM8OB2CDI0"
+ k = EcdsaPublicKey(s)
+
+def test___init__bytes():
+ k = EcdsaPublicKey(b"abcd"*(256//8//4))
+
+def test___init_EcdsaPublicKey():
+ k1 = EcdsaPublicKey(b"abcd"*(256//8//4))
+ k2 = EcdsaPublicKey(k1)
+ assert k1._data == k2._data
+
+def test___init__string_wrong_size():
+ with pytest.raises(ValueError):
+ k = EcdsaPublicKey("abcd")
+ with pytest.raises(ValueError):
+ k = EcdsaPublicKey("abcd"*256)
+
+def test___init__bytes_wrong_size():
+ with pytest.raises(ValueError):
+ k = EcdsaPublicKey(b"abcd")
+ with pytest.raises(ValueError):
+ k = EcdsaPublicKey(b"abcd"*256)
diff --git a/tests/unit/test_hashcode.py b/tests/unit/test_hashcode.py
new file mode 100644
index 0000000..d40cdd9
--- /dev/null
+++ b/tests/unit/test_hashcode.py
@@ -0,0 +1,32 @@
+import pytest
+
+from gnunet import HashCode
+
+def test___repr__():
+ k = HashCode(b"abcd"*(512//8//4))
+ assert repr(k).startswith('gnunet.HashCode(')
+
+def test___init__string():
+ s = ("C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P31C9HM8OB2CDI6"
+ "2OJ3CHGM4OR4C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P0")
+ k = HashCode(s)
+
+def test___init__bytes():
+ k = HashCode(b"abcd"*(512//8//4))
+
+def test___init_HashCode():
+ k1 = HashCode(b"abcd"*(512//8//4))
+ k2 = HashCode(k1)
+ assert k1._data == k2._data
+
+def test___init__string_wrong_size():
+ with pytest.raises(ValueError):
+ k = HashCode("abcd")
+ with pytest.raises(ValueError):
+ k = HashCode("abcd"*512)
+
+def test___init__bytes_wrong_size():
+ with pytest.raises(ValueError):
+ k = HashCode(b"abcd")
+ with pytest.raises(ValueError):
+ k = HashCode(b"abcd"*512)
--
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 <=
- [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, 2020/04/12
- [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