예제 #1
0
    def test_announcement_no_experimental(self, dispatch):
        runner = announcementrunner.get_runner()
        runner.action = mock.Mock(ref='some.thing')
        runner.runner_parameters = {
            'route': 'general'
        }
        runner.liveaction = mock.Mock(context={})

        expected_msg = 'Experimental flag is missing for action some.thing'
        self.assertRaisesRegexp(Exception, expected_msg, runner.pre_run)
예제 #2
0
    def test_announcement(self, dispatch):
        runner = announcementrunner.get_runner()
        runner.runner_parameters = {
            'experimental': True,
            'route': 'general'
        }
        runner.liveaction = mock.Mock(context={})

        runner.pre_run()
        (status, result, _) = runner.run({'test': 'passed'})

        self.assertEqual(status, LIVEACTION_STATUS_SUCCEEDED)
        self.assertTrue(result is not None)
        self.assertEqual(result['test'], 'passed')
        dispatch.assert_called_once_with('general', payload={'test': 'passed'},
                                         trace_context=None)
예제 #3
0
    def test_announcement_with_trace(self, context, dispatch):
        runner = announcementrunner.get_runner()
        runner.runner_parameters = {
            'experimental': True,
            'route': 'general'
        }
        runner.liveaction = mock.Mock(context={
            'trace_context': {
                'id_': 'a',
                'trace_tag': 'b'
            }
        })

        runner.pre_run()
        (status, result, _) = runner.run({'test': 'passed'})

        self.assertEqual(status, LIVEACTION_STATUS_SUCCEEDED)
        self.assertTrue(result is not None)
        self.assertEqual(result['test'], 'passed')
        context.assert_called_once_with(TraceContext,
                                        **runner.liveaction.context['trace_context'])
        dispatch.assert_called_once_with('general', payload={'test': 'passed'},
                                         trace_context=context.return_value)
예제 #4
0
 def test_runner_creation(self, dispatch):
     runner = announcementrunner.get_runner()
     self.assertTrue(runner is not None, 'Creation failed. No instance.')
     self.assertEqual(type(runner), announcementrunner.AnnouncementRunner,
                      'Creation failed. No instance.')
     self.assertEqual(runner._dispatcher.dispatch, dispatch)