Skip to content

Commit 1e86f18

Browse files
committed
Pytest and coverage
1 parent 6c32916 commit 1e86f18

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ For production see the recommended option using [Docker](https://www.docker.com/
5050

5151
### Step by step (ideal for development purposes)
5252

53-
Follow the steps below from within project folder to locally install the application:
53+
Follow the steps below from within the project folder to locally install the application:
5454

5555
- Install dependencies (recommended way using [Poetry](https://python-poetry.org/)):
5656
```bash
@@ -108,3 +108,21 @@ Provided that the application is up and running:
108108
- Visit http://localhost:8000/board/tests/ to view the available test runs.
109109

110110
- Visit http://localhost:8000/board/datacenter/datacenter_name/ to view results of tests for networks of a specific datacenter (replace *datacenter_name* with the name of your datacenter as it appears in https://www.fdsn.org/datacenters/). You can use the search form to view tests within a specific time frame.
111+
112+
## Testing (for development purposes)
113+
114+
To run the tests and get `coverage` information, run the below command from within the project folder:
115+
```bash
116+
pytest --cov-report html
117+
```
118+
119+
The report will be available in `htmlcov/index.html` file.
120+
121+
122+
## Things pending
123+
124+
- A few `ruff` errors are still not addressed. Most of them could probably be ignored though.
125+
126+
- Test suite is quite poor and needs more meaningful tests to increase coverage percentage.
127+
128+
- Maybe a good idea could be to use class based views.

poetry.lock

+86-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+17
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pytest = "^8.2.2"
1616
pytest-django = "^4.8.0"
1717
ruff = "^0.5.0"
1818
tqdm = "^4.66.4"
19+
pytest-cov = "^5.0.0"
1920

2021
[build-system]
2122
requires = ["poetry-core"]
@@ -31,3 +32,19 @@ lint.ignore = [
3132
"RUF012", # For django migration files
3233
]
3334
target-version = "py310"
35+
36+
[tool.pytest.ini_options]
37+
addopts = "--cov --no-migrations"
38+
DJANGO_SETTINGS_MODULE = "netstests.settings"
39+
testpaths = ["board"]
40+
python_files = ["tests.py", "test_*.py", "*_test.py"]
41+
42+
[tool.coverage.run]
43+
branch = true
44+
source = ["board"]
45+
omit = [
46+
"*/migrations/*",
47+
"*/tests/*",
48+
"asgi.py",
49+
"wsgi.py",
50+
]

0 commit comments

Comments
 (0)