示例#1
0
 def test_from_state_with_node_exists(self, mock_store):
     ActionRun.from_state(
         self.state_data,
         self.parent_context,
         self.output_path,
         self.run_node,
         lambda: None,
     )
     mock_store.get_instance().get_node.assert_called_with(
         self.state_data['node_name'],
         self.run_node,
     )
示例#2
0
 def test_from_state_before_rendered_command(self):
     self.state_data['command'] = 'do things %(actionname)s'
     self.state_data['rendered_command'] = None
     action_run = ActionRun.from_state(self.state_data, self.parent_context,
                                       self.output_path, self.run_node)
     assert_equal(action_run.bare_command, self.state_data['command'])
     assert not action_run.rendered_command
示例#3
0
 def test_from_state_after_rendered_command(self):
     self.state_data['command'] = 'do things theaction'
     self.state_data['rendered_command'] = self.state_data['command']
     action_run = ActionRun.from_state(self.state_data, self.parent_context,
                                       self.output_path, self.run_node)
     assert_equal(action_run.bare_command, self.state_data['command'])
     assert_equal(action_run.rendered_command, self.state_data['command'])
示例#4
0
 def test_from_state_after_rendered_command(self):
     self.state_data['command'] = 'do things theaction'
     self.state_data['rendered_command'] = self.state_data['command']
     action_run = ActionRun.from_state(self.state_data,
             self.parent_context, self.output_path, self.run_node)
     assert_equal(action_run.bare_command, self.state_data['command'])
     assert_equal(action_run.rendered_command, self.state_data['command'])
示例#5
0
 def test_from_state_before_rendered_command(self):
     self.state_data['command'] = 'do things %(actionname)s'
     self.state_data['rendered_command'] = None
     action_run = ActionRun.from_state(self.state_data,
             self.parent_context, self.output_path, self.run_node)
     assert_equal(action_run.bare_command, self.state_data['command'])
     assert not action_run.rendered_command
示例#6
0
 def test_from_state_running(self):
     self.state_data['state'] = 'running'
     action_run = ActionRun.from_state(self.state_data,
             self.parent_context, self.output_path, self.run_node)
     assert action_run.is_unknown
     assert_equal(action_run.exit_status, 0)
     assert_equal(action_run.end_time, self.now)
示例#7
0
 def test_from_state_running(self):
     self.state_data['state'] = 'running'
     action_run = ActionRun.from_state(self.state_data, self.parent_context,
                                       self.output_path, self.run_node)
     assert action_run.is_unknown
     assert_equal(action_run.exit_status, 0)
     assert_equal(action_run.end_time, self.now)
示例#8
0
 def test_from_state_no_node_name(self):
     del self.state_data['node_name']
     action_run = ActionRun.from_state(
         self.state_data,
         self.parent_context,
         self.output_path,
         self.run_node,
         lambda: None,
     )
     assert_equal(action_run.node, self.run_node)
示例#9
0
 def test_from_state_queued(self):
     self.state_data['state'] = 'queued'
     action_run = ActionRun.from_state(
         self.state_data,
         self.parent_context,
         self.output_path,
         self.run_node,
         lambda: None,
     )
     assert action_run.is_queued
示例#10
0
    def test_from_state_with_node_exists(self):
        anode = turtle.Turtle(name="anode", hostname="box")
        node_store = node.NodePoolStore.get_instance()
        node_store.put(anode)

        action_run = ActionRun.from_state(self.state_data,
                self.parent_context, self.output_path, self.run_node)

        assert_equal(action_run.node, anode)
        node_store.clear()
示例#11
0
 def test_from_state_old_state(self):
     self.state_data['command'] = 'do things {actionname}'
     action_run = ActionRun.from_state(
         self.state_data,
         self.parent_context,
         self.output_path,
         self.run_node,
         lambda: None,
     )
     assert_equal(action_run.bare_command, self.state_data['command'])
     assert not action_run.rendered_command
示例#12
0
    def test_from_state(self):
        state_data = self.state_data
        action_run = ActionRun.from_state(state_data, self.parent_context,
                list(self.output_path), self.run_node)

        for key, value in self.state_data.iteritems():
            if key in ['state', 'node_name']:
                continue
            assert_equal(getattr(action_run, key), value)

        assert action_run.is_succeeded
        assert not action_run.is_cleanup
        assert_equal(action_run.output_path[:2], self.output_path)
示例#13
0
    def test_from_state(self):
        state_data = self.state_data
        action_run = ActionRun.from_state(state_data, self.parent_context,
                                          list(self.output_path),
                                          self.run_node)

        for key, value in self.state_data.iteritems():
            if key in ['state', 'node_name']:
                continue
            assert_equal(getattr(action_run, key), value)

        assert action_run.is_succeeded
        assert not action_run.is_cleanup
        assert_equal(action_run.output_path[:2], self.output_path)
示例#14
0
 def test_from_state_with_node_exists(self, mock_store):
     ActionRun.from_state(self.state_data,
             self.parent_context, self.output_path, self.run_node)
     mock_store.get_instance().get_node.assert_called_with(
         self.state_data['node_name'], self.run_node)
示例#15
0
 def test_from_state_no_node_name(self):
     del self.state_data['node_name']
     action_run = ActionRun.from_state(self.state_data,
             self.parent_context, self.output_path, self.run_node)
     assert_equal(action_run.node, self.run_node)
示例#16
0
 def test_from_state_queued(self):
     self.state_data['state'] = 'queued'
     action_run = ActionRun.from_state(self.state_data, self.parent_context,
             self.output_path, self.run_node)
     assert action_run.is_queued
示例#17
0
 def test_from_state_queued(self):
     self.state_data['state'] = 'queued'
     action_run = ActionRun.from_state(self.state_data, self.parent_context,
             self.output_path, self.run_node)
     assert action_run.is_failed
     assert_equal(action_run.end_time, self.now)