Skip to content
Snippets Groups Projects
Commit e0a6fed1 authored by jan.bednarik's avatar jan.bednarik
Browse files

Setup for tests

parent b870eba4
No related branches found
No related tags found
1 merge request!11Calendar
default_language_version: default_language_version:
python: python3.7 python: python3.7
exclude: snapshots/
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0 rev: v2.5.0
......
...@@ -19,13 +19,17 @@ help: ...@@ -19,13 +19,17 @@ help:
@echo " migrations Generate migrations" @echo " migrations Generate migrations"
@echo " migrate Run migrations" @echo " migrate Run migrations"
@echo "" @echo ""
@echo "Testing:"
@echo " test Run tests"
@echo " coverage Coverage report"
@echo ""
venv: .venv/bin/python venv: .venv/bin/python
.venv/bin/python: .venv/bin/python:
${PYTHON} -m venv ${VENV} ${PYTHON} -m venv ${VENV}
install: venv install: venv
${VENV}/bin/pip install -r requirements/base.txt ${VENV}/bin/pip install -r requirements/base.txt -r requirements/dev.txt
install-hooks: install-hooks:
pre-commit install --install-hooks pre-commit install --install-hooks
...@@ -45,7 +49,13 @@ migrations: venv ...@@ -45,7 +49,13 @@ migrations: venv
migrate: venv migrate: venv
${VENV}/bin/python manage.py migrate ${VENV}/bin/python manage.py migrate
test:
${VENV}/bin/pytest
coverage:
${VENV}/bin/pytest --cov --cov-report term-missing
.PHONY: help venv install install-hooks hooks run shell .PHONY: help venv install install-hooks hooks run shell
.PHONY: migrations migrate .PHONY: migrations migrate test coverage
# EOF # EOF
...@@ -153,6 +153,20 @@ Django shell používající `shell_plus` z Django extensions spustíte: ...@@ -153,6 +153,20 @@ Django shell používající `shell_plus` z Django extensions spustíte:
$ make shell $ make shell
### Testy
Používá se testovací framework [pytest](https://pytest.org). Spuštění testů:
$ pytest
Případně přes `make`, ale bez možnosti parametrizovat spuštění testů:
$ make test
Coverage report:
$ make coverage
### Code quality ### Code quality
K formátování kódu se používá [black](https://github.com/psf/black). Doporučujeme K formátování kódu se používá [black](https://github.com/psf/black). Doporučujeme
...@@ -187,5 +201,6 @@ K upgrade se používají [pip-tools](https://github.com/jazzband/pip-tools) (`p ...@@ -187,5 +201,6 @@ K upgrade se používají [pip-tools](https://github.com/jazzband/pip-tools) (`p
$ cd requirements/ $ cd requirements/
$ pip-compile -U base.in $ pip-compile -U base.in
$ pip-compile -U production.in $ pip-compile -U production.in
$ pip-compile -U dev.in
Tím se vygenerují `base.txt` a `production.txt`. Tím se vygenerují `base.txt`, `production.txt` a `dev.txt`.
[pytest]
addopts = --ds=majak.settings.dev
python_files = test_*.py
pytest
pytest-sugar
pytest-factoryboy
pytest-cov
pytest-django
pytest-freezegun
snapshottest
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile dev.in
#
attrs==19.3.0 # via pytest
coverage==5.1 # via pytest-cov
factory-boy==2.12.0 # via pytest-factoryboy
faker==4.1.0 # via factory-boy
fastdiff==0.2.0 # via snapshottest
freezegun==0.3.15 # via pytest-freezegun
inflection==0.4.0 # via pytest-factoryboy
more-itertools==8.3.0 # via pytest
packaging==20.4 # via pytest, pytest-sugar
pluggy==0.13.1 # via pytest
py==1.8.1 # via pytest
pyparsing==2.4.7 # via packaging
pytest-cov==2.8.1 # via -r dev.in
pytest-django==3.9.0 # via -r dev.in
pytest-factoryboy==2.0.3 # via -r dev.in
pytest-freezegun==0.4.1 # via -r dev.in
pytest-sugar==0.9.3 # via -r dev.in
pytest==5.4.2 # via -r dev.in, pytest-cov, pytest-django, pytest-factoryboy, pytest-freezegun, pytest-sugar
python-dateutil==2.8.1 # via faker, freezegun
six==1.14.0 # via freezegun, packaging, python-dateutil, snapshottest
snapshottest==0.5.1 # via -r dev.in
termcolor==1.1.0 # via pytest-sugar, snapshottest
text-unidecode==1.3 # via faker
wasmer==0.4.1 # via fastdiff
wcwidth==0.1.9 # via pytest
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment