Пример #1
0
 def fake_request(self,
                  operation,
                  on_success=lambda: None,
                  on_error=lambda: None):
     request = SQuery(Task(self.fake_client()), operation, 1,
                      lambda s: None)
     request.on_error = on_error
     request.on_success = on_success
     return request
Пример #2
0
 def query(self,
           service_name,
           operation,
           on_success=lambda: None,
           on_error=lambda: None):
     request = Query(self.a_running_task(), operation, 1, lambda s: None)
     request.on_success = on_success
     request.on_error = on_error
     self.send(request, service_name)
     return request
Пример #3
0
    def do_test_response_time(self, sent_at, replied_at):
        sender = MagicMock()
        type(sender.schedule).time_now = PropertyMock(side_effect=[sent_at, replied_at])
        request = Query(Task(sender), "foo_operation", 1, lambda s: None)

        recipient = MagicMock()

        request.send_to(recipient)
        request.reply_success()

        self.assertEqual(replied_at - sent_at, request.response_time)
Пример #4
0
    def test_response_time_on_error(self):
        sender = MagicMock()
        sender.schedule.time = MagicMock(return_value=(5, 10, 15))
        request = Query(Task(sender), "foo_operation", 1, lambda s: None)

        recipient = MagicMock()

        request.send_to(recipient)
        request.reply_error()

        with self.assertRaises(AssertionError):
            request.response_time
Пример #5
0
    def do_test_response_time(self, sent_at, replied_at):
        sender = MagicMock()
        type(sender.schedule).time_now = PropertyMock(side_effect = [sent_at, replied_at] )
        request = Query(Task(sender), "foo_operation", 1, lambda s: None)

        recipient = MagicMock()

        request.send_to(recipient)
        request.reply_success()

        self.assertEqual(replied_at - sent_at, request.response_time)
Пример #6
0
    def test_response_time_on_error(self):
        sender = MagicMock()
        sender.schedule.time = MagicMock(return_value = (5, 10, 15))
        request = Query(Task(sender), "foo_operation", 1, lambda s: None)

        recipient = MagicMock()

        request.send_to(recipient)
        request.reply_error()

        with self.assertRaises(AssertionError):
            request.response_time
Пример #7
0
 def fake_request(self, operation, on_success=lambda: None, on_error=lambda: None):
     request = SQuery(Task(self.fake_client()), operation, 1, lambda s: None)
     request.on_error = on_error
     request.on_success = on_success
     return request
Пример #8
0
 def create_query(self, task, operation, priority, continuation):
     return Query(task, operation, priority, continuation)
Пример #9
0
 def query(self, service_name, operation, on_success=lambda:None, on_error=lambda:None):
     request = Query(self.a_running_task(), operation, 1, lambda s:None)
     request.on_success = on_success
     request.on_error = on_error
     self.send(request, service_name)
     return request