Beispiel #1
0
    def test_ctx_get_all(self):
        data = {
            "__vars": {
                "a": 123,
                "b": "foobar",
                "c": True,
                "d": None,
                "e": {
                    "foobar": "fubar"
                },
                "f": ["foobar", "fubar"],
                "__state": {
                    "foobar": "fubar"
                },
            }
        }

        expected_data = {
            "a": 123,
            "b": "foobar",
            "c": True,
            "d": None,
            "e": {
                "foobar": "fubar"
            },
            "f": ["foobar", "fubar"],
        }

        self.assertDictEqual(funcs.ctx_(data), expected_data)
Beispiel #2
0
    def test_ctx_get_all(self):
        data = {
            '__vars': {
                'a': 123,
                'b': 'foobar',
                'c': True,
                'd': None,
                'e': {'foobar': 'fubar'},
                'f': ['foobar', 'fubar'],
                '__state': {
                    'foobar': 'fubar'
                }
            }
        }

        expected_data = {
            'a': 123,
            'b': 'foobar',
            'c': True,
            'd': None,
            'e': {'foobar': 'fubar'},
            'f': ['foobar', 'fubar']
        }

        self.assertDictEqual(funcs.ctx_(data), expected_data)
Beispiel #3
0
    def test_ctx_get_by_key(self):
        data = {
            '__vars': {
                'a': 123,
                'b': 'foobar',
                'c': True,
                'd': None,
                'e': {'foobar': 'fubar'},
                'f': ['foobar', 'fubar']
            }
        }

        self.assertEqual(funcs.ctx_(data, 'a'), 123)
        self.assertEqual(funcs.ctx_(data, 'b'), 'foobar')
        self.assertTrue(funcs.ctx_(data, 'c'))
        self.assertIsNone(funcs.ctx_(data, 'd'))
        self.assertDictEqual(funcs.ctx_(data, 'e'), {'foobar': 'fubar'})
        self.assertListEqual(funcs.ctx_(data, 'f'), ['foobar', 'fubar'])
Beispiel #4
0
    def test_ctx_get_by_key(self):
        data = {
            "__vars": {
                "a": 123,
                "b": "foobar",
                "c": True,
                "d": None,
                "e": {
                    "foobar": "fubar"
                },
                "f": ["foobar", "fubar"],
            }
        }

        self.assertEqual(funcs.ctx_(data, "a"), 123)
        self.assertEqual(funcs.ctx_(data, "b"), "foobar")
        self.assertTrue(funcs.ctx_(data, "c"))
        self.assertIsNone(funcs.ctx_(data, "d"))
        self.assertDictEqual(funcs.ctx_(data, "e"), {"foobar": "fubar"})
        self.assertListEqual(funcs.ctx_(data, "f"), ["foobar", "fubar"])