コード例 #1
0
ファイル: actionrun_test.py プロジェクト: dennistu1994/Tron
    def setup_action_runs(self):
        self.run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
        a1 = MagicMock()
        a1.name = 'act1'
        a2 = MagicMock()
        a2.name = 'act2'
        actions = [a1, a2]
        self.action_graph = actiongraph.ActionGraph(
            actions,
            {a.name: a
             for a in actions},
        )

        mock_node = mock.create_autospec(node.Node)
        self.job_run = jobrun.JobRun(
            'jobname',
            7,
            self.run_time,
            mock_node,
            action_graph=self.action_graph,
        )

        self.action_state_data = {
            'job_run_id': 'job_run_id',
            'action_name': 'act1',
            'state': 'succeeded',
            'run_time': 'the_run_time',
            'start_time': None,
            'end_time': None,
            'command': 'do action1',
            'node_name': 'anode',
        }
        self.action_runner = mock.create_autospec(
            actioncommand.SubprocessActionRunnerFactory, )
コード例 #2
0
    def setup_action_runs(self):
        self.run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
        actions = [Turtle(name='act1'), Turtle(name='act2')]
        self.action_graph = actiongraph.ActionGraph(
            actions, dict((a.name, a) for a in actions))

        mock_node = mock.create_autospec(node.Node)
        self.job_run = jobrun.JobRun('jobname',
                                     7,
                                     self.run_time,
                                     mock_node,
                                     action_graph=self.action_graph)

        self.action_state_data = {
            'job_run_id': 'job_run_id',
            'action_name': 'act1',
            'state': 'succeeded',
            'run_time': 'the_run_time',
            'start_time': None,
            'end_time': None,
            'command': 'do action1',
            'node_name': 'anode'
        }
        self.action_runner = mock.create_autospec(
            actioncommand.SubprocessActionRunnerFactory)
コード例 #3
0
ファイル: job_test.py プロジェクト: terrorizer1980/Tron-2
def test_job_watch_notifies_about_runs(mock_job):
    # Separate from the above tests because we don't want
    # watch to be mocked here.
    new_run = jobrun.JobRun(
        job_name='test',
        run_num=1,
        run_time='some_time',
        node='node',
    )
    with mock.patch.object(
            mock_job,
            'handler',
    ) as mock_handler, mock.patch.object(
            mock_job,
            'notify',
    ) as mock_notify:
        mock_job.watch(new_run)

        # Make sure that the job is still watching correctly
        # by checking it handles events
        new_run.notify('test_event', 'test_data')
        assert mock_handler.call_args_list == [
            mock.call(new_run, 'test_event', 'test_data')
        ]

        # Check that the job notifies its watchers about a new run
        assert mock_notify.call_args_list == [
            mock.call(job.Job.NOTIFY_NEW_RUN, event_data=new_run)
        ]
コード例 #4
0
ファイル: jobrun_test.py プロジェクト: wfxiang08/Tron
 def setup_jobrun(self):
     self.job = build_mock_job()
     self.action_graph = self.job.action_graph
     self.run_time = datetime.datetime(2012, 3, 14, 15, 9 ,26)
     mock_node = mock.create_autospec(node.Node)
     self.job_run = jobrun.JobRun('jobname', 7, self.run_time, mock_node,
             action_runs=Turtle(
                 action_runs_with_cleanup=[],
                 get_startable_action_runs=lambda: []))
     autospec_method(self.job_run.watch)
     autospec_method(self.job_run.notify)
     self.job_run.event = mock.create_autospec(event.EventRecorder)
     self.action_run = mock.create_autospec(actionrun.ActionRun, is_skipped=False)