python-terraform-1 Make option with bool value/ more sense for the caller

merge-requests/1/head
Freddy Tan 8 years ago
parent 110a1f1c4f
commit bfd9b3a8ab

1
.gitignore vendored

@ -5,3 +5,4 @@
.idea
.cache
/.pypirc
/.tox/

@ -0,0 +1,3 @@
tox-pyenv
pytest
tox

@ -5,7 +5,7 @@ import logging
import re
logging.basicConfig(level=logging.WARN)
current_path = os.path.dirname(os.path.realpath(__file__))
STRING_CASES = [
[
@ -61,28 +61,40 @@ class TestTerraform:
@pytest.mark.parametrize(*CMD_CASES)
def test_cmd(self, method, expected_output):
tf = Terraform()
tf = Terraform(working_dir=current_path)
ret, out, err = method(tf)
assert expected_output in out
assert ret == 0
def test_state_data(self):
tf = Terraform(working_dir='test_tfstate_file', state='tfstate.test')
cwd = os.path.join(current_path, 'test_tfstate_file')
tf = Terraform(working_dir=cwd, state='tfstate.test')
tf.read_state_file()
assert tf.tfstate.modules[0]['path'] == ['root']
def test_apply(self):
tf = Terraform(working_dir='apply_tf', variables={'test_var': 'test'})
cwd = os.path.join(current_path, 'apply_tf')
tf = Terraform(working_dir=cwd, variables={'test_var': 'test'})
ret, out, err = tf.apply(var={'test_var': 'test2'})
assert ret == 0
def test_override_no_color(self):
cwd = os.path.join(current_path, 'apply_tf')
tf = Terraform(working_dir=cwd, variables={'test_var': 'test'})
ret, out, err = tf.apply(var={'test_var': 'test2'},
no_color=IsNotFlagged)
out = out.replace('\n', '')
assert '\x1b[0m\x1b[1m\x1b[32mApply' in out
def test_get_output(self):
tf = Terraform(working_dir='apply_tf', variables={'test_var': 'test'})
cwd = os.path.join(current_path, 'apply_tf')
tf = Terraform(working_dir=cwd, variables={'test_var': 'test'})
tf.apply()
assert tf.output('test_output') == 'test'
def test_destroy(self):
tf = Terraform(working_dir='apply_tf', variables={'test_var': 'test'})
cwd = os.path.join(current_path, 'apply_tf')
tf = Terraform(working_dir=cwd, variables={'test_var': 'test'})
ret, out, err = tf.destroy()
assert ret == 0
assert 'Destroy complete! Resources: 0 destroyed.' in out

@ -0,0 +1,6 @@
# content of: tox.ini , put in same dir as setup.py
[tox]
envlist = py27, py3
[testenv]
deps=pytest
commands=py.test test
Loading…
Cancel
Save