예제 #1
0
 def test_startService_markAllForUpdate_on_connect(self):
     listener = MagicMock()
     listener.events.connected = Event()
     service = self.make_service(listener)
     mock_mark_dns_for_update = self.patch(service, 'markDNSForUpdate')
     mock_mark_rbac_for_update = self.patch(service, 'markRBACForUpdate')
     mock_mark_proxy_for_update = self.patch(service, 'markProxyForUpdate')
     service.startService()
     service.postgresListener.events.connected.fire()
     mock_mark_dns_for_update.assert_called_once()
     mock_mark_rbac_for_update.assert_called_once()
     mock_mark_proxy_for_update.assert_called_once()
예제 #2
0
 def test_registerHandler_during_fire(self):
     event = Event()
     event.registerHandler(event.registerHandler)
     event.fire(sentinel.otherHandler)
     self.assertItemsEqual(
         [event.registerHandler, sentinel.otherHandler], event.handlers
     )
예제 #3
0
 def test_fire_calls_all_handlers(self):
     event = Event()
     handler_one = MagicMock()
     handler_two = MagicMock()
     event.registerHandler(handler_one)
     event.registerHandler(handler_two)
     args = [factory.make_name("arg") for _ in range(3)]
     kwargs = {
         factory.make_name("key"): factory.make_name("value")
         for _ in range(3)
     }
     event.fire(*args, **kwargs)
     self.assertThat(handler_one, MockCalledOnceWith(*args, **kwargs))
     self.assertThat(handler_two, MockCalledOnceWith(*args, **kwargs))
예제 #4
0
 def test_unregisterHandler_during_fire(self):
     event = Event()
     event.registerHandler(event.unregisterHandler)
     event.fire(event.unregisterHandler)
     self.assertItemsEqual([], event.handlers)
예제 #5
0
 def test_unregisterHandler(self):
     event = Event()
     event.registerHandler(sentinel.handler)
     event.unregisterHandler(sentinel.handler)
     self.assertItemsEqual([], event.handlers)