added markers; edited README.md
This commit is contained in:
39
README.md
39
README.md
@@ -196,6 +196,44 @@ function some_func() {
|
|||||||
|
|
||||||
````
|
````
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
|
||||||
|
We use `pytest` and several pytest plugins, especially the `pytest-django` and `pytest-cov` plugins that provide Django fixtures, and test coverage analysis.
|
||||||
|
|
||||||
|
In the root folder, `pytest.ini` contains configurations for running the tests, `requirements_testing.txt` contains the python packages required for running tests, and the folder `tests` contains the actual test files.
|
||||||
|
|
||||||
|
To run the tests, install the packages in requirements and requirements_testing.txt:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install -r requirements_testing.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
then simply run pytest
|
||||||
|
```
|
||||||
|
pytest
|
||||||
|
```
|
||||||
|
|
||||||
|
to generate the coverage html pages:
|
||||||
|
|
||||||
|
```
|
||||||
|
pytest --cov=. --cov-report html -v
|
||||||
|
```
|
||||||
|
|
||||||
|
the coverage html files will be generated in the `htmlcov` folder
|
||||||
|
|
||||||
|
We use `tox` to test the package against different isolated environments. `tox.ini` contains the configurations for tox. To run the tests in the environments defined in the `tox.ini` file, make sure the python package tox is installed:
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install tox
|
||||||
|
```
|
||||||
|
|
||||||
|
then run tox in the project root:
|
||||||
|
|
||||||
|
```
|
||||||
|
tox
|
||||||
|
```
|
||||||
|
|
||||||
# Contributors
|
# Contributors
|
||||||
* [mahmoodnasr](https://github.com/mahmoodnasr)
|
* [mahmoodnasr](https://github.com/mahmoodnasr)
|
||||||
* [d3cline](https://github.com/d3cline)
|
* [d3cline](https://github.com/d3cline)
|
||||||
@@ -207,6 +245,7 @@ function some_func() {
|
|||||||
* [ezrajrice](https://github.com/ezrajrice)
|
* [ezrajrice](https://github.com/ezrajrice)
|
||||||
* [Spitfireap](https://github.com/Spitfireap)
|
* [Spitfireap](https://github.com/Spitfireap)
|
||||||
* [peterthomassen](https://github.com/peterthomassen)
|
* [peterthomassen](https://github.com/peterthomassen)
|
||||||
|
* [oussjarrousse](https://github.com/oussjarrousse)
|
||||||
|
|
||||||
|
|
||||||
# Security contact information
|
# Security contact information
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ markers =
|
|||||||
NON_PRIVILEGED_USER: tests for non-privileged users
|
NON_PRIVILEGED_USER: tests for non-privileged users
|
||||||
PERMISSIONS: tests related to permissions
|
PERMISSIONS: tests related to permissions
|
||||||
|
|
||||||
|
ANNONYMOUS_USER: tests for non-authenticated users
|
||||||
|
AUTHENTICATED_USER: tests for authenticated users
|
||||||
|
|
||||||
ENDPOINTS: tests for endpoints (API nodes)
|
ENDPOINTS: tests for endpoints (API nodes)
|
||||||
SERIALIZERS: tests for serializers
|
SERIALIZERS: tests for serializers
|
||||||
VIEWS: tests for DRF viewsets
|
VIEWS: tests for DRF viewsets
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
@pytest.mark.VIEWS
|
||||||
|
@pytest.mark.DJANGO
|
||||||
|
@pytest.mark.ANNONYMOUS_USER
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_index_unauthenticated(client):
|
def test_index_unauthenticated(client):
|
||||||
url = reverse("mfa_home")
|
url = reverse("mfa_home")
|
||||||
@@ -9,7 +12,8 @@ def test_index_unauthenticated(client):
|
|||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert response.url=="/accounts/login/?next=/"
|
assert response.url=="/accounts/login/?next=/"
|
||||||
|
|
||||||
|
@pytest.mark.VIEWS
|
||||||
|
@pytest.mark.AUTHENTICATED_USER
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_index_authenticated(client, authenticated_user):
|
def test_index_authenticated(client, authenticated_user):
|
||||||
url = reverse("mfa_home")
|
url = reverse("mfa_home")
|
||||||
|
|||||||
Reference in New Issue
Block a user