def _setup(self): inst = ZkSharedCache("zk", "path", "handler") inst._path = "/path" inst._zk = create_mock(["is_connected"]) inst._kazoo = create_mock(["create", "set"]) inst._incoming_entries = create_mock(["append"]) return inst
def test_full(self, init): inst = ZkSharedCache("zk", "path", "handler") inst._zk = create_mock(["conn_epoch", "is_connected"]) inst._incoming_entries = create_mock(["__bool__", "popleft"]) inst._incoming_entries.__bool__.side_effect = True, True, False inst._incoming_entries.popleft.side_effect = ("inc0", 1), ("inc1", 0) inst._entries = {"inc0": 0, "old0": 0} inst._list_entries = create_mock() inst._list_entries.return_value = "inc0", "inc1", "new0" inst._handle_entries = create_mock() inst._path = "/path" # Call inst.process() # Tests ntools.eq_(inst._entries, {"inc0": 0, "inc1": 0}) inst._handle_entries.assert_called_once_with({"new0"})