From 803ea8404681ab5f6d93a181d6008c301e7afb8f Mon Sep 17 00:00:00 2001 From: Paco Hope Date: Sat, 13 Aug 2022 11:24:45 -0400 Subject: [PATCH 1/6] added .venv --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 235500f..5f473cd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ cfg/* __pycache__/ *.py[cod] *$py.class +.venv # C extensions *.so From db5bbb5915b5ca76ed002d8d378ccb497a84e1f6 Mon Sep 17 00:00:00 2001 From: Paco Hope Date: Sat, 13 Aug 2022 11:59:46 -0400 Subject: [PATCH 2/6] added for pytest integration --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index 58ea118..da599ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ pyyaml argparse pylint build +pytest +cli_test_helpers \ No newline at end of file From f652653097d3fb1f8a127c98165db61078e2796c Mon Sep 17 00:00:00 2001 From: Paco Hope Date: Sat, 13 Aug 2022 11:24:45 -0400 Subject: [PATCH 3/6] added .venv --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 235500f..5f473cd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ cfg/* __pycache__/ *.py[cod] *$py.class +.venv # C extensions *.so From b10217cbcb3f8bc532dc7088e5c6069bd2e54116 Mon Sep 17 00:00:00 2001 From: Paco Hope Date: Sat, 13 Aug 2022 11:59:46 -0400 Subject: [PATCH 4/6] added for pytest integration --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index 58ea118..da599ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ pyyaml argparse pylint build +pytest +cli_test_helpers \ No newline at end of file From 71447227f13d90b9fecba73f0feb1e78b7878cf0 Mon Sep 17 00:00:00 2001 From: Paco Hope Date: Sat, 13 Aug 2022 12:39:05 -0400 Subject: [PATCH 5/6] Needed to import sys --- src/tfscript/writing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tfscript/writing.py b/src/tfscript/writing.py index c704061..7138eaf 100644 --- a/src/tfscript/writing.py +++ b/src/tfscript/writing.py @@ -1,4 +1,5 @@ import os +import sys from os.path import exists from tempfile import NamedTemporaryFile From f8806480f3929b38ecd23eb2ed13e0335bfaba44 Mon Sep 17 00:00:00 2001 From: Paco Hope Date: Sat, 13 Aug 2022 12:39:33 -0400 Subject: [PATCH 6/6] Created first basic tests --- tests/test_cli.py | 38 ++++++++++++++++++++++++++++++++++++++ tests/test_valid_yaml.py | 15 +++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/test_cli.py create mode 100644 tests/test_valid_yaml.py diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..3f68015 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,38 @@ +""" +Tests that we can import and execute the most basic valid test file. +Uses: tests/validYAML.yaml +""" +import pytest +import tfscript.cli +from cli_test_helpers import ArgvContext, shell + +class TestCLI: + + def test_debug_opt(self): + """Is debug argument available?""" + with ArgvContext('tfscript', '-d', 'tests/validYAML.yaml'): + parser = tfscript.cli.parseCLI() + args = parser.parse_args() + assert args.debug == True + + def test_dry_run_opt(self): + """Is dry-run argument available?""" + with ArgvContext('tfscript', '-n', 'tests/validYAML.yaml'): + 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.""" + with ArgvContext('tfscript', '--directory', '.', 'tests/validYAML.yaml'): + 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") \ No newline at end of file diff --git a/tests/test_valid_yaml.py b/tests/test_valid_yaml.py new file mode 100644 index 0000000..b187722 --- /dev/null +++ b/tests/test_valid_yaml.py @@ -0,0 +1,15 @@ +""" +Tests that we can import and execute the most basic valid test file. +Uses: tests/validYAML.yaml +""" +import pytest +import tfscript.cli +from cli_test_helpers import ArgvContext, shell + +class TestValidYaml: + + def test_parseValidFile(self, tmp_path): + """Parse the basic test file.""" + with ArgvContext('tfscript', '--directory', str(tmp_path), + '-d', 'tests/validYAML.yaml'): + tfscript.cli.main()