예제 #1
0
    def test_first(self):
        mediator = Mediator()
        Mediator.register_handler(QueryWithTypedResponseHandler)

        genericQuery = QueryWithTypedResponse(name="mediatr 123")
        respModel = mediator.send(genericQuery)
        self.assertEqual(genericQuery.some_name, respModel.some_name)
예제 #2
0
 def test_dispatch_sync_without_behavior(self):
     Mediator.register_handler(get_array_handler_sync)
     Mediator.register_handler(GetArrayQueryHandler)
     mediator = Mediator()
     query1 = GetArrayQuery(5)
     result1 = mediator.send(query1)
     self.assertEqual(len(result1), 5)
예제 #3
0
 def test_get_array_query_handler(self):
     ioloop = asyncio.get_event_loop()
     Mediator.register_handler(get_array_handler)
     mediator = Mediator()
     query = GetArrayQuery(5)
     result = ioloop.run_until_complete(mediator.send_async(query))
     array_count = len(result)
     self.assertEqual(5, array_count)
예제 #4
0
 def test_1(self):
     from tests.example_handlers_annotations import GetArrayQueryHandlerWithAnnotations
     from tests.example_queries import GetArrayQueryWithAnnotations
     Mediator.register_handler(GetArrayQueryHandlerWithAnnotations)
     query = GetArrayQueryWithAnnotations(5)
     self.assertEqual(query.items_count, 5)
     result = self.ioloop.run_until_complete(
         self.mediator.send_async(query))
     self.assertEqual(query.items_count, 5)
     array_count = len(result)
     self.assertEqual(5, array_count)
예제 #5
0
 def test_1(self):
     class Client:
         def test_1(self):
             return 'test_3'
     get_array_query_handler_with_constructor = GetArrayQueryHandlerWithConstructor(Client)
     Mediator.register_handler(get_array_query_handler_with_constructor)
     query = GetArrayQueryWithConstructor(5)
     self.assertEqual(query.items_count, 5)
     result = self.ioloop.run_until_complete(self.mediator.send_async(query))
     self.assertEqual(query.items_count, 5)
     array_count = len(result)
     self.assertEqual(5, array_count)
예제 #6
0
 def test_get_array_query_handler_with_behavior(self):
     ioloop = asyncio.get_event_loop()
     Mediator.register_handler(get_array_handler)
     Mediator.register_behavior(get_array_query_behavior)
     Mediator.register_behavior(get_array_query_behavior_3)
     mediator = Mediator()
     query = GetArrayQuery(5)
     self.assertEqual(query.items_count, 5)
     result = ioloop.run_until_complete(mediator.send_async(query))
     self.assertEqual(query.items_count, 3)
     array_count = len(result)
     self.assertEqual(3, array_count)
예제 #7
0
 async def test_dispatch_sync(self):
     Mediator.register_handler(get_array_handler_sync)
     Mediator.register_handler(GetArrayQueryHandler)
     Mediator.register_behavior(common_log_behavior)
     mediator = Mediator()
     query1 = GetArrayQuery(5)
     result1 = mediator.send(query1)
     self.assertEqual(len(result1), 5)
     self.assertIsNotNone(query1.updated_at)
     query2 = GetArrayQuery1(4)
     result2 = mediator.send(query2)
     self.assertEqual(len(result2), 4)
     self.assertIsNotNone(query2.updated_at)
예제 #8
0
 def test_1(self):
     Mediator.register_handler(get_array_handler)
     Mediator.register_handler(GetArrayQueryHandler)
     Mediator.register_behavior(common_log_behavior)
     mediator = Mediator()
     query1 = GetArrayQuery(5)
     result1 = self.ioloop.run_until_complete(mediator.send_async(query1))
     self.assertEqual(len(result1), 5)
     self.assertIsNotNone(query1.updated_at)
     query2 = GetArrayQuery1(4)
     result2 = self.ioloop.run_until_complete(mediator.send_async(query2))
     self.assertEqual(len(result2), 4)
     self.assertIsNotNone(query2.updated_at)
예제 #9
0
    def test_first(self):

        Mediator.register_handler(get_array_handler_sync)
        Mediator.register_handler(GetArrayQueryHandler)
        Mediator.register_handler(QueryWithTypedResponseHandler)
        Mediator.register_behavior(common_log_behavior)
        Mediator.register_behavior(print_before)

        query1 = GetArrayQuery(5)
        result1 = Mediator.send(query1)
        self.assertEqual(len(result1), 5)
        self.assertIsNotNone(query1.updated_at)
        query2 = GetArrayQuery1(4)
        result2 = Mediator.send(query2)
        self.assertEqual(len(result2), 4)
        self.assertIsNotNone(query2.updated_at)
        self.assertEqual(query1.updated_at, '123')
        self.assertEqual(query2.updated_at, '123')
        self.assertTrue(query2.common_bahavior_handled)
예제 #10
0
 def test_register_handler(self):
     Mediator.register_handler(get_array_handler)
     self.assertEqual(len(__handlers__.keys()), 1)