From 29977a9c52e95ac58cbc402908e26998788f0820 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 11 Oct 2022 12:44:15 +0300 Subject: Add tests for monadic_dict * tests/unit/test_monads.py (test_monadic_dict): Add basic test-cases for MonadicDict. --- tests/unit/test_monads.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/unit/test_monads.py (limited to 'tests/unit') 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 -- cgit v1.2.3