gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

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