diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..5be15ba --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[report] +show_missing = True +omit = + manage.py + venv/* + *wsgi.py \ No newline at end of file diff --git a/Makefile b/Makefile index 0ca9547..327c2e1 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,34 @@ +.DEFAULT_GOAL := help + +help: ## show help message + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + + .PHONY: build_frontend run_frontend run_django run install_dependencies setup_node_environment -build_frontend: +build_frontend: ## build frontend application npm run build -run_frontend: +run_frontend: ## run frontend application npm start -run_django: +run_django: ## run backend application python manage.py runserver -run: +run: ## run both backend and frontend applications make -j2 run_django run_frontend -install_dependencies: +install_dependencies: ## install both backend and frontend dependencies make setup_node_environment pip install -r requirements.txt npm i -setup_node_environment: +setup_node_environment: ## setup node environment curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash export NVM_DIR=$$HOME/.nvm; . ~/.nvm/nvm.sh ; nvm install + +test: ## run the tests + pytest + +cov: ## run the tests, and open coverage report in your favorite browser + pytest && python -m webbrowser -t htmlcov/index.html \ No newline at end of file diff --git a/README.md b/README.md index 25336c8..e6687f7 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ make run Since nvm can be a little fiddly, if you have any issues with it, [try reading their documentation](https://github.com/nvm-sh/nvm#installing-and-updating) on how to use it. +## Testing it + +Run the command `pytest` in the main directory, or run the script `make test`. + +For coverage report, run the script `make cov`. Your default browser will open with the report for the tests, if all tests pass. + ## Adding new dependencies If you wish to add new dependencies, just note that: diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..8a86196 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,6 @@ +[pytest] +DJANGO_SETTINGS_MODULE = project.settings + +python_files = test.py test_*.py *_tests.py + +addopts = --cov-report html --cov . \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 077bc50..cc493ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ asgiref==3.2.5 attrs==19.3.0 black==19.10b0 click==7.1.1 +coverage==5.5 dj-database-url==0.5.0 Django==3.0.4 django-heroku==0.3.1 @@ -12,15 +13,25 @@ djangorestframework==3.11.0 entrypoints==0.3 flake8==3.7.9 gunicorn==20.0.4 +iniconfig==1.1.1 mccabe==0.6.1 +packaging==20.9 pathspec==0.7.0 +pluggy==0.13.1 psycopg2==2.8.4 +py==1.10.0 pycodestyle==2.5.0 pyflakes==2.1.1 +pyparsing==2.4.7 +pytest==6.2.4 +pytest-cov==2.12.1 +pytest-django==4.4.0 +pytest-sugar==0.9.4 python-decouple==3.3 pytz==2019.3 regex==2020.2.20 sqlparse==0.3.1 +termcolor==1.1.0 toml==0.10.0 typed-ast==1.4.1 whitenoise==5.0.1 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_sample.py b/tests/test_sample.py new file mode 100644 index 0000000..a6f1c78 --- /dev/null +++ b/tests/test_sample.py @@ -0,0 +1,2 @@ +def test_sample(): + assert True \ No newline at end of file