def test_parse_message_and_validate_invalid(self):
        handler = InputJsonMessageHandler()
        with self.assertRaises(ValidationError) as ctx:
            handler.parse_message(self.INVALID_MESSAGE_1)

        self.assertEqual(ctx.exception.message,
                         "'value' is a required property")

        with self.assertRaises(ValidationError) as ctx:
            handler.parse_message(self.INVALID_MESSAGE_2)

        self.assertEqual(ctx.exception.message, "'ts' is a required property")

        with self.assertRaises(ValidationError) as ctx:
            handler.parse_message(self.INVALID_MESSAGE_3)

        self.assertEqual(ctx.exception.message,
                         "'application' is a required property")
 def test_extract_value(self):
     handler = InputJsonMessageHandler()
     in_message = handler.parse_message(self.VALID_MESSAGE)
     self.assertEqual(handler.extract_value(in_message), 0.87)
 def test_extract_ts(self):
     handler = InputJsonMessageHandler()
     in_message = handler.parse_message(self.VALID_MESSAGE)
     self.assertEqual(handler.extract_ts(in_message), datetime(2018, 1, 1))
 def test_parse_message_and_validate(self):
     handler = InputJsonMessageHandler()
     in_message = handler.parse_message(self.VALID_MESSAGE)
     self.assertEqual(handler.validate_message(in_message), True)