about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-10-11 12:44:15 +0300
committerBonfaceKilz2022-11-02 17:36:22 +0300
commit29977a9c52e95ac58cbc402908e26998788f0820 (patch)
treeacc7ee45a76a1acfcad698b8790b6728bbf1f707 /tests
parent97fa5c174d15858f7466190d7707a36486c19fbe (diff)
downloadgenenetwork3-29977a9c52e95ac58cbc402908e26998788f0820.tar.gz
Add tests for monadic_dict
* tests/unit/test_monads.py (test_monadic_dict): Add basic test-cases
for MonadicDict.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_monads.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/test_monads.py b/tests/unit/test_monads.py
new file mode 100644
index 0000000..9ae07be
--- /dev/null
+++ b/tests/unit/test_monads.py
@@ -0,0 +1,23 @@
+"""Test cases for functions defined in monads.py"""
+import pytest
+
+from pymonad.maybe import Just, Nothing
+from gn3.monads import MonadicDict
+
+
+@pytest.mark.unit_test
+@pytest.mark.parametrize(
+    ("key", "value", "expected"),
+    (
+        ("foo", Just(1), Just(1)),
+        ("bar", Nothing, Nothing),
+    ),
+)
+def test_monadic_dict(key, value, expected):
+    """Test basic Monadic Dict operations"""
+    _test_dict = MonadicDict()
+    _test_dict[key] = value
+    _test_dict |= {"test_update": "random"}
+    assert _test_dict[key] == expected
+    assert _test_dict["test_update"] == Just("random")
+    assert _test_dict["non-existent"] == Nothing