2022-08-13 12:39:33 -04:00
|
|
|
"""
|
|
|
|
Tests that we can import and execute the most basic valid test file.
|
2022-08-13 16:03:43 -04:00
|
|
|
Uses: tests/basic_test.yaml
|
2022-08-13 12:39:33 -04:00
|
|
|
"""
|
|
|
|
import pytest
|
|
|
|
import tfscript.cli
|
|
|
|
from cli_test_helpers import ArgvContext, shell
|
|
|
|
|
|
|
|
class TestCLI:
|
|
|
|
|
|
|
|
def test_debug_opt(self):
|
|
|
|
"""Is debug argument available?"""
|
2022-08-13 16:03:43 -04:00
|
|
|
with ArgvContext('tfscript', '-d', 'tests/basic_test.yaml'):
|
2022-08-13 12:39:33 -04:00
|
|
|
parser = tfscript.cli.parseCLI()
|
|
|
|
args = parser.parse_args()
|
|
|
|
assert args.debug == True
|
|
|
|
|
|
|
|
def test_dry_run_opt(self):
|
|
|
|
"""Is dry-run argument available?"""
|
2022-08-13 16:03:43 -04:00
|
|
|
with ArgvContext('tfscript', '-n', 'tests/basic_test.yaml'):
|
2022-08-13 12:39:33 -04:00
|
|
|
parser = tfscript.cli.parseCLI()
|
|
|
|
args = parser.parse_args()
|
|
|
|
assert args.dry_run == True
|
|
|
|
|
|
|
|
def test_directory_opt(self):
|
|
|
|
"""Use . because it's sure to exist on all platforms."""
|
2022-08-13 16:03:43 -04:00
|
|
|
with ArgvContext('tfscript', '--directory', '.', 'tests/basic_test.yaml'):
|
2022-08-13 12:39:33 -04:00
|
|
|
parser = tfscript.cli.parseCLI()
|
|
|
|
args = parser.parse_args()
|
|
|
|
assert args.directory == '.'
|
|
|
|
|
|
|
|
def test_cli(self):
|
|
|
|
"""
|
|
|
|
Does CLI stop execution w/o a filename positional argument?
|
|
|
|
"""
|
|
|
|
with pytest.raises(SystemExit):
|
|
|
|
tfscript.cli.main()
|
|
|
|
pytest.fail("Should abort without positional filename argument")
|