コード例 #1
0
 async def test_create_message(self):
     """
     Testing whether message creation works.
     """
     loop = self._asyncioTestLoop
     nats = NatsHandler("test", "0.0.0.0", "4222", loop=loop, user="******", password="******")
     nats.time_sent = "2020-07-06"
     nats.sender_id = "1"
     message = nats.create_message({
                     "testData": "This is a test"
                 }, MessageSchemas.TEST_MESSAGE)
     self.assertEqual(message.sender_id, "1")
     self.assertEqual(message.time_sent, "2020-07-06")
     self.assertEqual(message.data, {
                     "testData": "This is a test"
                 })
     with self.assertRaises(ValidationError):
         message = nats.create_message({
                     "testData": "This is a test"
                 }, MessageSchemas.ORBIT_MESSAGE)
コード例 #2
0
 async def simulation_timepulse(message: Message,
                                nats_handler: NatsHandler,
                                shared_storage: dict,
                                logger: JsonLogger):
     nats_handler.time_sent = message.data["time"]