def test_handler_respond_get_action_name(self): obj1 = handle_respond.HandlerRespond(app_name=self.app_name) obj2 = handle_respond.HandlerRespond(self.app_name, "any action name") self.assertIsNone( obj1.get_action_name(self.test_payload, self.test_user1)) self.assertIsNotNone( obj2.get_action_name(self.test_payload, self.test_user1))
def test_handler_respond_run(self): self.assertIsNotNone(handle_respond.TextPreprocessingResult(self.test_payload.get("message", {}))) self.assertIsNotNone(handle_respond.log_const.KEY_NAME) self.assertIsNotNone(handle_respond.log_const.NORMALIZED_TEXT_VALUE) self.assertIsNotNone(handle_respond.TextPreprocessingResult(self.test_payload.get("message", {})).raw) obj1 = handle_respond.HandlerRespond(app_name=self.app_name) obj2 = handle_respond.HandlerRespond(self.app_name, "any action name") with self.assertRaises(KeyError): obj1.run(self.test_payload, self.test_user1) self.assertTrue(obj2.run(self.test_payload, self.test_user2) == 10)
def test_handler_respond_get_action_params(self): obj = handle_respond.HandlerRespond(app_name=self.app_name) self.assertTrue( obj.get_action_params(self.test_payload, self.test_user2) == self.callback11_action_params) self.assertTrue( obj.get_action_params("any data", self.test_user2) == self.callback11_action_params) self.assertTrue( obj.get_action_params(None, self.test_user2) == self.callback11_action_params)
def test_handler_respond_init(self): obj1 = handle_respond.HandlerRespond(app_name=self.app_name) obj2 = handle_respond.HandlerRespond(self.app_name, "any action name") self.assertIsNotNone(obj1.KAFKA_KEY) self.assertIsNone(obj1._action_name) self.assertIsNotNone(obj2._action_name)
def test_handler_respond_get_action_params(self): obj = handle_respond.HandlerRespond(app_name=self.app_name) self.assertTrue(obj.get_action_params(self.test_payload) == {}) self.assertTrue(obj.get_action_params("any data") == {}) self.assertTrue(obj.get_action_params(None) == {})