def test_log_no_target_name(self):
     with mock.patch('openstack.common.request_utils.LOG') as mylog:
         request_utils.link_request_ids(None, "source_id",
                                        stage="start")
         self.assertTrue(mylog.info.called)
         self.assertEqual(mylog.info.call_args, mock.call(
             u"Request ID Link: request.link.start 'source_id'"))
    def test_log_no_target_id(self):
        with mock.patch('openstack.common.request_utils.LOG') as mylog:
            request_utils.link_request_ids(None, "source_id",
                                           stage="start",
                                           target_name="network service")
            self.assertTrue(mylog.info.called)
            self.assertEqual(mylog.info.call_args, mock.call(
                u"Request ID Link: request.link.start 'source_id' -> "
                "Target='network service' "))

            self.assertFalse(self.notifier.info.called)
    def test_happy_day(self):
        with mock.patch('openstack.common.request_utils.LOG') as mylog:
            request_utils.link_request_ids(None, "source_id",
                                           target_id="target_id",
                                           stage="start",
                                           target_name="network service",
                                           notifier=self.notifier)
            self.assertTrue(mylog.info.called)
            self.assertEqual(mylog.info.call_args, mock.call(
                u"Request ID Link: request.link.start 'source_id' -> "
                "Target='network service' TargetId=target_id "))

            payload = {"source_request_id": "source_id",
                       "target_request_id": "target_id",
                       "target_name": "network service",
                       "stage": "start"}
            self.assertEqual(self.notifier.info.call_args,
                             mock.call(None, "request.link.start", payload))