From bd5c9af9ce4f13b4f9d1f94dfc18df21da1dcf32 Mon Sep 17 00:00:00 2001 From: Estella Song Date: Wed, 29 Jun 2022 19:00:31 -0700 Subject: [PATCH 1/8] able to specify which tests to run --- dev.sh | 3 ++- entrypoint.sh | 3 +-- requirements_3.10.txt | 42 ---------------------------------- test.sh | 29 +++++++++++++++++++++++ test_suite.sh | 26 +++++++++++++++++++-- tests/webapp/tests/new_test.py | 3 +++ 6 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 test.sh create mode 100644 tests/webapp/tests/new_test.py diff --git a/dev.sh b/dev.sh index 407495a..1aed2e4 100755 --- a/dev.sh +++ b/dev.sh @@ -9,7 +9,8 @@ case $1 in ;; validate) - docker run docker-python-base validatecodeonce + # docker run docker-python-base validatecodeonce -h + docker run docker-python-base validatecodeonce -k new ;; cli) diff --git a/entrypoint.sh b/entrypoint.sh index 20dad62..74c2ef4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -53,9 +53,8 @@ validatecode() { validatecodeonce() { echo -e "\nTriggering single run of code validation." - loadconfig - ../test_suite.sh reports + ../test_suite.sh $@ reports } diff --git a/requirements_3.10.txt b/requirements_3.10.txt index 3bcea5d..66c4473 100644 --- a/requirements_3.10.txt +++ b/requirements_3.10.txt @@ -1,46 +1,4 @@ -anyio==3.5.0 -argh==0.26.2 -asgiref==3.5.1 -attrs==21.4.0 -black==22.3.0 -click==8.1.3 -colorama==0.4.4 -coverage==6.3.2 -fastapi==0.75.2 -flake8==4.0.1 -flake8-isort==4.1.1 -flake8-print==5.0.0 -flake8-quotes==3.3.1 -h11==0.13.0 -idna==3.3 -iniconfig==1.1.1 -interrogate==1.5.0 -isort==5.10.1 -loguru==0.6.0 -mccabe==0.6.1 -mypy==0.950 -mypy-extensions==0.4.3 -nest-asyncio==1.5.5 -packaging==21.3 -pathspec==0.9.0 -platformdirs==2.5.2 -pluggy==1.0.0 -py==1.11.0 -pycodestyle==2.8.0 -pydantic==1.9.0 -pyflakes==2.4.0 -pyparsing==3.0.8 pytest==7.1.2 pytest-asyncio==0.18.3 pytest-cov==3.0.0 pytest-mock==3.7.0 -PyYAML==6.0 -sniffio==1.2.0 -starlette==0.17.1 -tabulate==0.8.9 -testfixtures==6.18.5 -toml==0.10.2 -tomli==2.0.1 -typing_extensions==4.2.0 -uvicorn==0.17.6 -watchdog==2.1.7 diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..b18f5e6 --- /dev/null +++ b/test.sh @@ -0,0 +1,29 @@ +# help() +# { +# commands +# # Display Help +# echo "Trigger a single run of code validation." +# echo +# echo "Syntax: validatecodeonce [reports] [-h|]" +# echo +# echo "Positional arguments:" +# echo "reports Save test results in ${REPORTS_FOLDER}". +# echo +# echo "Options:" +# echo "h Print this help." +# echo "n Invokes Pytest option -k to run specific tests based on a substring match to the test name." +# echo +# } + +# help +# # help +# # echo "Hello world!" + +# while getopts ":h" option; do +# case $option in +# h) # display Help +# help +# exit;; +# esac +# done +echo $@ \ No newline at end of file diff --git a/test_suite.sh b/test_suite.sh index 662f46b..5a7487e 100755 --- a/test_suite.sh +++ b/test_suite.sh @@ -3,6 +3,29 @@ REPORTS_FOLDER="/python/reports/" SECTION_PREFIX="\n#########" +help() { + echo "Help Menu" + echo + echo "Syntax: validatecodeonce [reports] [-h|]" + echo + echo "Positional arguments:" + echo "reports Save test results in ${REPORTS_FOLDER}". + echo + echo "Options:" + echo "h Print this help menu." + echo "k Invokes Pytest option -k to run specific tests based on a substring match to the test name." + echo +} + +while getopts ":h:k:" option; do + case $option in + h) + help + exit;; + k) + SPECIFIC_TESTS="-k ${OPTARG}" + esac +done checkuser() { WHOAMI=`whoami` @@ -13,7 +36,6 @@ checkuser() { fi } - reportvalidation() { if [ -z "$1" ] then @@ -35,7 +57,7 @@ then fi echo -ne "$SECTION_PREFIX RUN TESTS:\n\n" -python -m pytest -vv --durations=3 --cov ./ --cov-report term-missing $PYTEST_REPORTS; STATUS1=$? +python -m pytest -vv --durations=3 --cov ./ --cov-report term-missing $PYTEST_REPORTS $SPECIFIC_TESTS; STATUS1=$? echo -ne "$SECTION_PREFIX CHECK DOCKER USER IS PYTHON: " USEROUT=`checkuser` diff --git a/tests/webapp/tests/new_test.py b/tests/webapp/tests/new_test.py new file mode 100644 index 0000000..0927af0 --- /dev/null +++ b/tests/webapp/tests/new_test.py @@ -0,0 +1,3 @@ +def test_something(): + """Just a test to have something for pytest to chew on""" + assert False From 229c46f9f7a1873dba3f6a70da1d30d7556806e3 Mon Sep 17 00:00:00 2001 From: Estella Song Date: Wed, 29 Jun 2022 19:03:02 -0700 Subject: [PATCH 2/8] remove test code --- dev.sh | 3 +-- entrypoint.sh | 1 + requirements_3.10.txt | 42 ++++++++++++++++++++++++++++++++++ test.sh | 29 ----------------------- tests/webapp/tests/new_test.py | 3 --- 5 files changed, 44 insertions(+), 34 deletions(-) delete mode 100644 test.sh delete mode 100644 tests/webapp/tests/new_test.py diff --git a/dev.sh b/dev.sh index 1aed2e4..407495a 100755 --- a/dev.sh +++ b/dev.sh @@ -9,8 +9,7 @@ case $1 in ;; validate) - # docker run docker-python-base validatecodeonce -h - docker run docker-python-base validatecodeonce -k new + docker run docker-python-base validatecodeonce ;; cli) diff --git a/entrypoint.sh b/entrypoint.sh index 74c2ef4..97d2311 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -53,6 +53,7 @@ validatecode() { validatecodeonce() { echo -e "\nTriggering single run of code validation." + loadconfig ../test_suite.sh $@ reports } diff --git a/requirements_3.10.txt b/requirements_3.10.txt index 66c4473..3bcea5d 100644 --- a/requirements_3.10.txt +++ b/requirements_3.10.txt @@ -1,4 +1,46 @@ +anyio==3.5.0 +argh==0.26.2 +asgiref==3.5.1 +attrs==21.4.0 +black==22.3.0 +click==8.1.3 +colorama==0.4.4 +coverage==6.3.2 +fastapi==0.75.2 +flake8==4.0.1 +flake8-isort==4.1.1 +flake8-print==5.0.0 +flake8-quotes==3.3.1 +h11==0.13.0 +idna==3.3 +iniconfig==1.1.1 +interrogate==1.5.0 +isort==5.10.1 +loguru==0.6.0 +mccabe==0.6.1 +mypy==0.950 +mypy-extensions==0.4.3 +nest-asyncio==1.5.5 +packaging==21.3 +pathspec==0.9.0 +platformdirs==2.5.2 +pluggy==1.0.0 +py==1.11.0 +pycodestyle==2.8.0 +pydantic==1.9.0 +pyflakes==2.4.0 +pyparsing==3.0.8 pytest==7.1.2 pytest-asyncio==0.18.3 pytest-cov==3.0.0 pytest-mock==3.7.0 +PyYAML==6.0 +sniffio==1.2.0 +starlette==0.17.1 +tabulate==0.8.9 +testfixtures==6.18.5 +toml==0.10.2 +tomli==2.0.1 +typing_extensions==4.2.0 +uvicorn==0.17.6 +watchdog==2.1.7 diff --git a/test.sh b/test.sh deleted file mode 100644 index b18f5e6..0000000 --- a/test.sh +++ /dev/null @@ -1,29 +0,0 @@ -# help() -# { -# commands -# # Display Help -# echo "Trigger a single run of code validation." -# echo -# echo "Syntax: validatecodeonce [reports] [-h|]" -# echo -# echo "Positional arguments:" -# echo "reports Save test results in ${REPORTS_FOLDER}". -# echo -# echo "Options:" -# echo "h Print this help." -# echo "n Invokes Pytest option -k to run specific tests based on a substring match to the test name." -# echo -# } - -# help -# # help -# # echo "Hello world!" - -# while getopts ":h" option; do -# case $option in -# h) # display Help -# help -# exit;; -# esac -# done -echo $@ \ No newline at end of file diff --git a/tests/webapp/tests/new_test.py b/tests/webapp/tests/new_test.py deleted file mode 100644 index 0927af0..0000000 --- a/tests/webapp/tests/new_test.py +++ /dev/null @@ -1,3 +0,0 @@ -def test_something(): - """Just a test to have something for pytest to chew on""" - assert False From 58eb029f3fae6e199241fc54214276adfad16bd0 Mon Sep 17 00:00:00 2001 From: Estella Song Date: Wed, 29 Jun 2022 19:21:41 -0700 Subject: [PATCH 3/8] specifically add help menu to validatecodeonce --- dev.sh | 2 +- entrypoint.sh | 20 ++++++++++++++++++++ test_suite.sh | 16 +--------------- tests/webapp/tests/dsadsad.py | 3 +++ 4 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 tests/webapp/tests/dsadsad.py diff --git a/dev.sh b/dev.sh index 407495a..1fa70e0 100755 --- a/dev.sh +++ b/dev.sh @@ -9,7 +9,7 @@ case $1 in ;; validate) - docker run docker-python-base validatecodeonce + docker run docker-python-base validatecodeonce -h ;; cli) diff --git a/entrypoint.sh b/entrypoint.sh index 97d2311..241deb9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -52,6 +52,26 @@ validatecode() { } validatecodeonce() { + help() { + echo + echo "Usage: validatecodeonce [-h|k]" + echo + echo "Trigger a single run of code validation." + echo + echo "Options:" + echo "h Print this help menu." + echo "k Invoke Pytest option -k to run specific tests based on a substring match to the test name." + echo + } + + while getopts ":h" option; do + case $option in + h) + help + exit;; + esac + done + echo -e "\nTriggering single run of code validation." loadconfig diff --git a/test_suite.sh b/test_suite.sh index 5a7487e..e130dc7 100755 --- a/test_suite.sh +++ b/test_suite.sh @@ -3,21 +3,7 @@ REPORTS_FOLDER="/python/reports/" SECTION_PREFIX="\n#########" -help() { - echo "Help Menu" - echo - echo "Syntax: validatecodeonce [reports] [-h|]" - echo - echo "Positional arguments:" - echo "reports Save test results in ${REPORTS_FOLDER}". - echo - echo "Options:" - echo "h Print this help menu." - echo "k Invokes Pytest option -k to run specific tests based on a substring match to the test name." - echo -} - -while getopts ":h:k:" option; do +while getopts ":k:" option; do case $option in h) help diff --git a/tests/webapp/tests/dsadsad.py b/tests/webapp/tests/dsadsad.py new file mode 100644 index 0000000..3692a91 --- /dev/null +++ b/tests/webapp/tests/dsadsad.py @@ -0,0 +1,3 @@ +def test_something(): + """Just a test to have something for pytest to chew on""" + assert True From ccc1be31d906a87fcd842391eb685c8403befa76 Mon Sep 17 00:00:00 2001 From: Estella Song Date: Wed, 29 Jun 2022 19:37:35 -0700 Subject: [PATCH 4/8] some reorganization --- dev.sh | 2 +- test_suite.sh | 3 --- tests/webapp/tests/dsadsad.py | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 tests/webapp/tests/dsadsad.py diff --git a/dev.sh b/dev.sh index 1fa70e0..27d0a0a 100755 --- a/dev.sh +++ b/dev.sh @@ -9,7 +9,7 @@ case $1 in ;; validate) - docker run docker-python-base validatecodeonce -h + docker run docker-python-base validatecodeonce -k simple ;; cli) diff --git a/test_suite.sh b/test_suite.sh index e130dc7..35535fb 100755 --- a/test_suite.sh +++ b/test_suite.sh @@ -5,9 +5,6 @@ SECTION_PREFIX="\n#########" while getopts ":k:" option; do case $option in - h) - help - exit;; k) SPECIFIC_TESTS="-k ${OPTARG}" esac diff --git a/tests/webapp/tests/dsadsad.py b/tests/webapp/tests/dsadsad.py deleted file mode 100644 index 3692a91..0000000 --- a/tests/webapp/tests/dsadsad.py +++ /dev/null @@ -1,3 +0,0 @@ -def test_something(): - """Just a test to have something for pytest to chew on""" - assert True From a413a3d55d557e8942a895888b5d925edf5d4e90 Mon Sep 17 00:00:00 2001 From: Estella Song Date: Wed, 29 Jun 2022 19:39:12 -0700 Subject: [PATCH 5/8] remove test code --- dev.sh | 2 +- entrypoint.sh | 1 - test_suite.sh | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev.sh b/dev.sh index 27d0a0a..407495a 100755 --- a/dev.sh +++ b/dev.sh @@ -9,7 +9,7 @@ case $1 in ;; validate) - docker run docker-python-base validatecodeonce -k simple + docker run docker-python-base validatecodeonce ;; cli) diff --git a/entrypoint.sh b/entrypoint.sh index 241deb9..f879636 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -73,7 +73,6 @@ validatecodeonce() { done echo -e "\nTriggering single run of code validation." - loadconfig ../test_suite.sh $@ reports } diff --git a/test_suite.sh b/test_suite.sh index 35535fb..d1f7c07 100755 --- a/test_suite.sh +++ b/test_suite.sh @@ -19,6 +19,7 @@ checkuser() { fi } + reportvalidation() { if [ -z "$1" ] then From 12fc34f38318e9a9f9da3d74471261141f4ea45d Mon Sep 17 00:00:00 2001 From: Estella Song Date: Tue, 5 Jul 2022 16:35:28 -0700 Subject: [PATCH 6/8] add options documentation for validatecodeonce --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index cfcecfd..a6cf2fb 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,11 @@ code change. This can be used for CI/CD purposes since it generates report files in the `/python/reports` folder. +Options: + +`-h` Print help menu.\ +`-k` Invoke Pytest option `-k` to run specific tests based on a substring match to the test name. + ### `runtests` (DEPRECATED) **DEPRECATED**: Use `validatecodeonce` instead From 8c14d177c68fe5953866825d605c2db8cff1279e Mon Sep 17 00:00:00 2001 From: Estella Song Date: Tue, 5 Jul 2022 16:36:08 -0700 Subject: [PATCH 7/8] better spacing --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index a6cf2fb..e8ea2c0 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,7 @@ code change. This can be used for CI/CD purposes since it generates report files in the `/python/reports` folder. -Options: - +Options:\ `-h` Print help menu.\ `-k` Invoke Pytest option `-k` to run specific tests based on a substring match to the test name. From 682611c17d2b2f364e5ec4330c19140809623e73 Mon Sep 17 00:00:00 2001 From: Estella Song Date: Mon, 18 Jul 2022 18:20:20 -0700 Subject: [PATCH 8/8] update docs with examples --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e8ea2c0..fc6f360 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,14 @@ This can be used for CI/CD purposes since it generates report files in the `/pyt folder. Options:\ -`-h` Print help menu.\ +`-h` Print help menu. +``` +validatecodeonce -h +``` `-k` Invoke Pytest option `-k` to run specific tests based on a substring match to the test name. +``` +validatecodeonce -k test_get_products +``` ### `runtests` (DEPRECATED)