Esempio n. 1
0
    def test_execute_fail(self, exec_command):
        """Test executing a command unsuccessfully"""
        exec_command.side_effect = [(1, ['Fail'])]

        entry = GraphEntry('/var', [])
        exit_code, stdout, changes_detected = entry.execute('plan')

        self.assertEqual(exit_code, 1)
        self.assertEqual(stdout, ['Fail'])
        self.assertEqual(changes_detected, True)
Esempio n. 2
0
    def test_execute(self, exec_command):
        """Test executing a command successfully"""
        exec_command.side_effect = [(0, ['Success'])]

        entry = GraphEntry('/var', [])
        exit_code, stdout, changes_detected = entry.execute('plan')

        self.assertEqual(exit_code, 0)
        self.assertEqual(stdout, ['Success', '\n'])
        self.assertEqual(changes_detected, False)
Esempio n. 3
0
    def test_execute_apply_changes(self, exec_command):
        """Test executing apply with changes"""
        exec_command.side_effect = [
            (0, ['Success']),
            (0, ['Success']),
        ]

        entry = GraphEntry('/var', [])
        exit_code, stdout, changes_detected = entry.execute('apply')

        self.assertEqual(exit_code, 0)
        self.assertEqual(stdout, ['Success', '\n', 'Success'])
        self.assertEqual(changes_detected, True)
Esempio n. 4
0
    def test_execute_apply_no_changes(self, exec_command):
        """Test executing apply with no changes"""
        exec_command.side_effect = [
            (0, ['Success']),
            (0, ['Resources: 0 added, 0 changed, 0 destroyed']),
        ]

        entry = GraphEntry('/var', [])
        exit_code, stdout, changes_detected = entry.execute('apply')

        self.assertEqual(exit_code, 0)
        self.assertEqual(
            stdout,
            ['Success', '\n', 'Resources: 0 added, 0 changed, 0 destroyed'])
        self.assertEqual(changes_detected, False)
Esempio n. 5
0
 def _get_or_create_entry(self, node: str):
     """
     Gets an entry from the graph dictionary or create it if it does not exist
     :param node: The node used to fetch the graph entry
     :return: The graph entry
     """
     if self.graph_dict.get(node):
         entry = self.graph_dict.get(node)
     else:
         entry = GraphEntry(node, [])
         self.graph_dict[node] = entry
     return entry