diff options
author | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2019-01-19 20:28:56 +0100 |
---|---|---|
committer | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2019-01-19 20:28:56 +0100 |
commit | 4309d80e3f8be6bfcf911cf75ea691694a0dbb15 (patch) | |
tree | ac75b9b3ee615ea200b42fc107360f0931a099f6 | |
parent | bda184f81ea7865067b4bcd73cef42251bff0217 (diff) | |
download | gnunet-python-4309d80e3f8be6bfcf911cf75ea691694a0dbb15.tar.gz gnunet-python-4309d80e3f8be6bfcf911cf75ea691694a0dbb15.zip |
Add a small test-suite.
-rw-r--r-- | tests/unit/test_crypto.py | 31 | ||||
-rw-r--r-- | tests/unit/test_hashcode.py | 32 |
2 files changed, 63 insertions, 0 deletions
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 @@ | |||
1 | import pytest | ||
2 | |||
3 | from gnunet.crypto import EcdsaPublicKey | ||
4 | |||
5 | def test___repr__(): | ||
6 | k = EcdsaPublicKey(b"abcd"*(256//8//4)) | ||
7 | assert repr(k).startswith('gnunet.crypto.EcdsaPublicKey(') | ||
8 | |||
9 | def test___init__string(): | ||
10 | s = "C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P31C9HM8OB2CDI0" | ||
11 | k = EcdsaPublicKey(s) | ||
12 | |||
13 | def test___init__bytes(): | ||
14 | k = EcdsaPublicKey(b"abcd"*(256//8//4)) | ||
15 | |||
16 | def test___init_EcdsaPublicKey(): | ||
17 | k1 = EcdsaPublicKey(b"abcd"*(256//8//4)) | ||
18 | k2 = EcdsaPublicKey(k1) | ||
19 | assert k1._data == k2._data | ||
20 | |||
21 | def test___init__string_wrong_size(): | ||
22 | with pytest.raises(ValueError): | ||
23 | k = EcdsaPublicKey("abcd") | ||
24 | with pytest.raises(ValueError): | ||
25 | k = EcdsaPublicKey("abcd"*256) | ||
26 | |||
27 | def test___init__bytes_wrong_size(): | ||
28 | with pytest.raises(ValueError): | ||
29 | k = EcdsaPublicKey(b"abcd") | ||
30 | with pytest.raises(ValueError): | ||
31 | 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 @@ | |||
1 | import pytest | ||
2 | |||
3 | from gnunet import HashCode | ||
4 | |||
5 | def test___repr__(): | ||
6 | k = HashCode(b"abcd"*(512//8//4)) | ||
7 | assert repr(k).startswith('gnunet.HashCode(') | ||
8 | |||
9 | def test___init__string(): | ||
10 | s = ("C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P31C9HM8OB2CDI6" | ||
11 | "2OJ3CHGM4OR4C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P0") | ||
12 | k = HashCode(s) | ||
13 | |||
14 | def test___init__bytes(): | ||
15 | k = HashCode(b"abcd"*(512//8//4)) | ||
16 | |||
17 | def test___init_HashCode(): | ||
18 | k1 = HashCode(b"abcd"*(512//8//4)) | ||
19 | k2 = HashCode(k1) | ||
20 | assert k1._data == k2._data | ||
21 | |||
22 | def test___init__string_wrong_size(): | ||
23 | with pytest.raises(ValueError): | ||
24 | k = HashCode("abcd") | ||
25 | with pytest.raises(ValueError): | ||
26 | k = HashCode("abcd"*512) | ||
27 | |||
28 | def test___init__bytes_wrong_size(): | ||
29 | with pytest.raises(ValueError): | ||
30 | k = HashCode(b"abcd") | ||
31 | with pytest.raises(ValueError): | ||
32 | k = HashCode(b"abcd"*512) | ||