예제 #1
0
 def test_generate_wo_link(self):
     rule = Rule(env='test', config=config, message='')
     work_plan_id = '1234'
     link = rule._generate_wo_link(work_plan_id)
     self.assertEqual(
         link,
         '{}://{}:{}/{}/{}/{}'.format(config.link.protocol,
                                      config.link.root, config.link.port,
                                      PATH_WORK_ORDER_BEGIN, work_plan_id,
                                      PATH_WORK_ORDER_END))
예제 #2
0
    def test_common_work_order_with_id(self):
        message = self.FakeMessage(event_type=EVENT_WO_DISPATCHED,
                                   timestamp=datetime.now().isoformat(),
                                   user_identifier='*****@*****.**',
                                   metadata={
                                       'sample_custodian': '*****@*****.**',
                                       'work_order_id': 1234
                                   },
                                   notifier_info={
                                       'work_plan_id': 1,
                                       'drs_study_code': 1234
                                   })
        rule = Rule(env='test', config=config, message=message)
        rule._generate_wo_link = Mock()
        rule._generate_wo_link.return_value = ''

        to, data = rule._common_work_order()

        self.assertEqual(to, [message.user_identifier])
        self.assertEqual(data, {
            'work_order_id': message.metadata['work_order_id'],
            'link': ''
        })