示例#1
0
    def test_announcement_no_experimental(self, dispatch):
        runner = announcement_runner.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_runner_creation(self, dispatch):
     runner = announcement_runner.get_runner()
     self.assertIsNotNone(runner, "Creation failed. No instance.")
     self.assertEqual(
         type(runner),
         announcement_runner.AnnouncementRunner,
         "Creation failed. No instance.",
     )
     self.assertEqual(runner._dispatcher.dispatch, dispatch)
示例#3
0
    def test_announcement_no_experimental(self, dispatch):
        runner = announcement_runner.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)
示例#4
0
    def test_announcement(self, dispatch):
        runner = announcement_runner.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.assertIsNotNone(result)
        self.assertEqual(result['test'], 'passed')
        dispatch.assert_called_once_with('general',
                                         payload={'test': 'passed'},
                                         trace_context=None)
示例#5
0
    def test_announcement(self, dispatch):
        runner = announcement_runner.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.assertIsNotNone(result)
        self.assertEqual(result["test"], "passed")
        dispatch.assert_called_once_with("general",
                                         payload={"test": "passed"},
                                         trace_context=None)
示例#6
0
    def test_announcement(self, dispatch):
        runner = announcement_runner.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)
示例#7
0
    def test_announcement_with_trace(self, context, dispatch):
        runner = announcement_runner.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.assertIsNotNone(result)
        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)
示例#8
0
    def test_announcement_with_trace(self, context, dispatch):
        runner = announcement_runner.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.assertIsNotNone(result)
        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)
示例#9
0
    def test_announcement_with_trace(self, context, dispatch):
        runner = announcement_runner.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)
示例#10
0
 def test_runner_creation(self, dispatch):
     runner = announcement_runner.get_runner()
     self.assertTrue(runner is not None, 'Creation failed. No instance.')
     self.assertEqual(type(runner), announcement_runner.AnnouncementRunner,
                      'Creation failed. No instance.')
     self.assertEqual(runner._dispatcher.dispatch, dispatch)
示例#11
0
 def test_runner_creation(self, dispatch):
     runner = announcement_runner.get_runner()
     self.assertTrue(runner is not None, 'Creation failed. No instance.')
     self.assertEqual(type(runner), announcement_runner.AnnouncementRunner,
                      'Creation failed. No instance.')
     self.assertEqual(runner._dispatcher.dispatch, dispatch)