Ejemplo n.º 1
0
 def _setup(self, check_ret=True):
     check = create_mock()
     check.return_value = check_ret
     reply = create_mock()
     inst = RequestHandler("queue", check, "fetch", reply)
     inst._expire_reqs = create_mock()
     return inst
Ejemplo n.º 2
0
 def _setup(self, time_, check_ret):
     check = create_mock_full(return_value=check_ret)
     fetch = create_mock()
     inst = RequestHandler("queue", check, fetch, "reply")
     inst._expire_reqs = create_mock()
     time_.return_value = 2
     return inst
Ejemplo n.º 3
0
 def test_reqs(self, time_):
     inst = RequestHandler("queue", "check", "fetch", "reply", ttl=5)
     inst._req_map["key"] = [(0, "req0"), (1, "req1"), (2, "req2")]
     time_.return_value = 6
     # Call
     inst._expire_reqs("key")
     # Tests
     ntools.eq_(inst._req_map["key"], [(1, "req1"), (2, "req2")])
Ejemplo n.º 4
0
 def test(self):
     q = create_mock(["get"])
     q.get.side_effect = [("key0", "req0"), ("key1", None)]
     inst = RequestHandler(q, "check", "fetch", "reply")
     inst._add_req = create_mock()
     inst._answer_reqs = create_mock()
     inst._key_map = create_mock()
     inst._key_map.side_effect = ("key0map0", "key0map1"), ("key1map0", )
     # Call
     ntools.assert_raises(StopIteration, inst.run)
     # Tests
     inst._add_req.assert_called_once_with("key0", "req0")
     assert_these_calls(
         inst._answer_reqs,
         [call("key0map0"),
          call("key0map1"),
          call("key1map0")])
Ejemplo n.º 5
0
 def test_no_reqs(self):
     inst = RequestHandler("queue", "check", "fetch", "reply")
     # Call
     inst._expire_reqs("key")