def test_components_separate(self): '''A state change in one component should not affect other components.''' sed = StatusEdgeDetector() comp1_status1 = { 'component': 'foo', 'status': 'ok', 'type': 'bar', 'message': 'test' } self.assertEqual(sed.check_status(**comp1_status1), comp1_status1) comp2_status1 = { 'component': 'bar', 'status': 'ok', 'type': 'bar', 'message': 'another test' } self.assertEqual(sed.check_status(**comp2_status1), comp2_status1) comp2_status2 = { 'component': 'bar', 'status': 'degraded', 'type': 'bar', 'message': 'another test' } self.assertEqual(sed.check_status(**comp2_status2), comp2_status2) comp1_status2 = { 'component': 'foo', 'status': 'ok', 'type': 'bar', 'message': 'test' } self.assertEqual(sed.check_status(**comp1_status2), None)
def setup_transport(self): self.setup_cacerts() config = self.get_static_config() self.redis = yield TxRedisManager.from_config(config.redis_manager) self.web_resource = yield self.start_web_resources([ (GoConversationResource(self.handle_raw_inbound_message), "%s/messages.json" % (config.web_path)), (GoConversationResource(self.handle_raw_inbound_event), "%s/events.json" % (config.web_path)), (GoConversationHealthResource(self), config.health_path), ], config.web_port) self.status_detect = StatusEdgeDetector()
def test_status_change(self): '''If the status does change, the status should be returned.''' sed = StatusEdgeDetector() status1 = { 'component': 'foo', 'status': 'ok', 'type': 'bar', 'message': 'test'} self.assertEqual(sed.check_status(**status1), status1) status2 = { 'component': 'foo', 'status': 'degraded', 'type': 'bar', 'message': 'another test'} self.assertEqual(sed.check_status(**status2), status2)
def setup_transport(self): self._requests = {} self.request_gc = LoopingCall(self.manually_close_requests) self.clock = self.get_clock() self.request_gc.clock = self.clock self.request_gc.start(self.gc_requests_interval) rpc_resource = HttpRpcResource(self) rpc_resource = self.get_authenticated_resource(rpc_resource) # start receipt web resource self.web_resource = yield self.start_web_resources([ (rpc_resource, self.web_path), (HttpRpcHealthResource(self), self.health_path), ], self.web_port) self.status_detect = StatusEdgeDetector()
def test_type_change(self): '''A change in status type should result in the status being returned.''' sed = StatusEdgeDetector() status1 = { 'component': 'foo', 'status': 'ok', 'type': 'bar', 'message': 'test'} self.assertEqual(sed.check_status(**status1), status1) status2 = { 'component': 'foo', 'status': 'ok', 'type': 'baz', 'message': 'test'} self.assertEqual(sed.check_status(**status2), status2)
def setup_transport(self): config = self.get_static_config() self.request_dict = {} self.endpoint = config.twisted_endpoint self.resource = WeChatResource(self) self.factory = build_web_site({ config.health_path: HttpRpcHealthResource(self), config.web_path: self.resource, }) self.redis = yield TxRedisManager.from_config(config.redis_manager) self.server = yield self.endpoint.listen(self.factory) self.status_detect = StatusEdgeDetector() if config.wechat_menu: # not yielding because this shouldn't block startup d = self.get_access_token() d.addCallback(self.create_wechat_menu, config.wechat_menu)