From f2d12dfb443b15e218340f1ee6b4fcf50e66da6b Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Thu, 5 Dec 2019 21:25:47 +0100 Subject: [PATCH] Add tests for get_dict. --- biscuit/core/tests/test_data_helpers.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 biscuit/core/tests/test_data_helpers.py diff --git a/biscuit/core/tests/test_data_helpers.py b/biscuit/core/tests/test_data_helpers.py new file mode 100644 index 000000000..096903947 --- /dev/null +++ b/biscuit/core/tests/test_data_helpers.py @@ -0,0 +1,22 @@ +from biscuit.core.templatetags.data_helpers import get_dict + +def test_get_dict_object(): + class _Foo(object): + bar = 12 + + assert _Foo.bar == get_dict(_Foo, 'bar') + +def test_get_dict_dict(): + _foo = {'bar': 12} + + assert _foo['bar'] == get_dict(_foo, 'bar') + +def test_get_dict_list(): + _foo = [10, 11, 12] + + assert _foo[2] == get_dict(_foo, 2) + +def test_get_dict_invalid(): + _foo = 12 + + assert get_dict(_foo, 'bar') is None -- GitLab