Esempio n. 1
0
    def test_get(self):
        ctx = Mock()
        ctx.get.return_value = sentinel.get

        h = Handle(ctx)

        eq_(h.get(), sentinel.get)

        ctx.get.assert_called_once_with()
Esempio n. 2
0
    def test_get(self):
        ctx = Mock()
        ctx.get.return_value = sentinel.get

        h = Handle(ctx)

        eq_(h.get(), sentinel.get)

        ctx.get.assert_called_once_with()
Esempio n. 3
0
    def test_item_access(self):
        ctx = Mock()

        h = Handle(ctx)

        handle2 = h["foobar"]

        eq_(handle2._path, ["foobar"])
Esempio n. 4
0
    def test_attr_access(self):
        ctx = Mock()

        h = Handle(ctx)

        handle2 = h.foobar

        eq_(handle2._path, ["foobar"])
Esempio n. 5
0
    def test_call(self):
        ctx = Mock()
        ctx.call.return_value = sentinel.rtn

        h = Handle(ctx)

        eq_(h(sentinel.foo), sentinel.rtn)

        ctx.call.assert_called_once_with((sentinel.foo, ))
Esempio n. 6
0
    def test_attr_set(self):
        ctx = Mock()
        h = Handle(ctx)

        h.key = sentinel.val
        ctx.set.assert_called_once_with("key", sentinel.val)
Esempio n. 7
0
    def test_item_set(self):
        ctx = Mock()
        h = Handle(ctx)

        h["key"] = sentinel.val
        ctx.set.assert_called_once_with("key", sentinel.val)
Esempio n. 8
0
    def test_attr_set(self):
        ctx = Mock()
        h = Handle(ctx)

        h.key = sentinel.val
        ctx.set.assert_called_once_with("key", sentinel.val)
Esempio n. 9
0
 def test_access_context_stays(self):
     ctx = Mock()
     h = Handle(ctx)
     handle2 = h.foobar
     eq_(handle2._context, ctx)