def test_task_status_notification(self): db = self.evaluate( DefineService("DB", DefineOperation("Select", Think(5) ) ) ).value listener = MagicMock(Listener) db.environment.look_up(Symbols.LISTENER).register(listener) self.query("DB", "Select") self.query("DB", "Select") self.simulate_until(15) expected_calls = [ call.task_created(ANY), call.task_accepted(ANY), call.task_assigned_to(ANY, ANY), call.task_created(ANY), call.task_accepted(ANY), call.task_activated(ANY), call.task_successful(ANY), call.task_assigned_to(ANY, ANY), call.task_successful(ANY), ] self.assertEqual(expected_calls, listener.method_calls, listener.method_calls)
def test_task_status_notification(self): db = self.evaluate( DefineService("DB", DefineOperation("Select", Think(5)))).value listener = MagicMock(Listener) db.environment.look_up(Symbols.LISTENER).register(listener) self.query("DB", "Select") self.query("DB", "Select") self.simulate_until(15) expected_calls = [ call.task_created(ANY), call.task_accepted(ANY), call.task_assigned_to(ANY, ANY), call.task_created(ANY), call.task_accepted(ANY), call.task_activated(ANY), call.task_successful(ANY), call.task_assigned_to(ANY, ANY), call.task_successful(ANY), ] self.assertEqual(expected_calls, listener.method_calls, listener.method_calls)
def test_server_notifies_rejection(self): db = self.evaluate( DefineService("DB", DefineOperation("Select", Think(5)))).value fake_task_pool = MagicMock(ThrottlingPolicyDecorator) fake_task_pool._accepts = MagicMock(return_value=False) db.tasks = ThrottlingWrapper(db.environment, task_pool=fake_task_pool) listener = MagicMock(Listener) db.environment.look_up(Symbols.LISTENER).register(listener) request1 = self.query("DB", "Select") request2 = self.query("DB", "Select") self.simulate_until(10) expected_calls = [ call.task_created(ANY), call.task_accepted(ANY), call.task_assigned_to(ANY, ANY), call.task_created(ANY), call.task_rejected(ANY), call.task_successful(ANY) ] self.assertEqual(expected_calls, listener.method_calls, listener.method_calls)
def test_server_notifies_rejection(self): db = self.evaluate( DefineService("DB", DefineOperation("Select", Think(5) ) ) ).value fake_task_pool = MagicMock(ThrottlingPolicyDecorator) fake_task_pool._accepts = MagicMock(return_value=False) db.tasks = ThrottlingWrapper(db.environment, task_pool=fake_task_pool) listener = MagicMock(Listener) db.environment.look_up(Symbols.LISTENER).register(listener) request1 = self.query("DB", "Select") request2 = self.query("DB", "Select") self.simulate_until(10) expected_calls = [ call.task_created(ANY), call.task_accepted(ANY), call.task_assigned_to(ANY, ANY), call.task_created(ANY), call.task_rejected(ANY), call.task_successful(ANY)] self.assertEqual(expected_calls, listener.method_calls, listener.method_calls)