Beispiel #1
0
    def __init__(self, command_executor, **kwargs):
        """
        :type command_executor:  BaseCommandExecutor
        :param command_executor: Command Line Executor
        :type parameters:  dict
        :param parameters: CLI arguments
        """

        self.terraform = Terraform(command_executor, **kwargs)
Beispiel #2
0
 def test_destroy(self):
     expected_args = [
         'terraform', 'destroy', '-no-color', '-auto-approve', '-var',
         "'test=[\"Test\", \"Test2\"]'"
     ]
     tf = Terraform(self.command_executor_mock,
                    variables={'test': ['Test', 'Test2']})
     tf.destroy()
     self.command_executor_mock.run.assert_called()
     args, kwargs = self.command_executor_mock.run.call_args
     for i in expected_args:
         self.assertIn(i, args[0])
Beispiel #3
0
 def test_apply(self):
     expected_args = [
         'terraform', 'apply', '-no-color', '-auto-approve', '-var',
         "'test=Test'"
     ]
     tf = Terraform(self.command_executor_mock,
                    variables={
                        'test': 'Test',
                        'no_value': None
                    })
     tf.apply()
     self.command_executor_mock.run.assert_called()
     args, kwargs = self.command_executor_mock.run.call_args
     for i in expected_args:
         self.assertIn(i, args[0])
Beispiel #4
0
 def test_wrong_command_executor(self):
     types = [str, int, list, dict, set, tuple]
     for executor_type in types:
         with self.assertRaises(DLabException):
             Terraform(MagicMock(spec=executor_type))
Beispiel #5
0
 def test_wrong_parameters_type(self):
     with self.assertRaises(DLabException):
         Terraform(self.command_executor_mock, no_color='')
Beispiel #6
0
 def test_output(self):
     Terraform(self.command_executor_mock).output()
     self.command_executor_mock.run.assert_called_with(
         'terraform output -json')
Beispiel #7
0
 def test_validate(self):
     self.command_executor_mock.run.return_value = TF_VALIDATE_SUCCESS_MSG
     Terraform(self.command_executor_mock).validate()
     self.command_executor_mock.run.assert_called_with('terraform validate')
Beispiel #8
0
 def test_failed_initialize(self):
     self.command_executor_mock.run.return_value = "error"
     with self.assertRaises(TerraformException):
         Terraform(self.command_executor_mock).initialize()
Beispiel #9
0
 def test_initialize(self):
     self.command_executor_mock.run.return_value = TF_INIT_SUCCESS_MSG
     Terraform(self.command_executor_mock).initialize()
     self.command_executor_mock.run.assert_called_with('terraform init')