diff --git a/biscuit/core/tests/test_data_helpers.py b/biscuit/core/tests/test_data_helpers.py new file mode 100644 index 0000000000000000000000000000000000000000..096903947c8c21870ad5c05fcffb5b0a8e522a12 --- /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