Example #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()
Example #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()
Example #3
0
    def test_item_access(self):
        ctx = Mock()

        h = Handle(ctx)

        handle2 = h["foobar"]

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

        h = Handle(ctx)

        handle2 = h.foobar

        eq_(handle2._path, ["foobar"])
Example #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, ))
Example #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)
Example #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)
Example #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)
Example #9
0
 def test_access_context_stays(self):
     ctx = Mock()
     h = Handle(ctx)
     handle2 = h.foobar
     eq_(handle2._context, ctx)