Skip to content

Commit 5394041

Browse files
committed
EDITED the developing locally doc.
1 parent ed1c74a commit 5394041

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

docs/developing-locally.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ First things first.
2929

3030
#. Create a new PostgreSQL database using createdb_: ::
3131

32-
$ createdb <what you've entered as the project_slug at setup stage>
32+
$ createdb <what you have entered as the project_slug at setup stage> -U postgres --password <password>
3333

3434
.. note::
3535

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Contents:
1717
developing-locally-docker
1818
settings
1919
linters
20+
testing
2021
deployment-on-pythonanywhere
2122
deployment-on-heroku
2223
deployment-with-docker

docs/testing.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.. _testing:
2+
3+
Testing
4+
========
5+
6+
We encourage users to build application tests. As best practice, this should be done immediately after documentation of the application being built, before starting on any coding.
7+
8+
Pytest
9+
------
10+
11+
This project uses the Pytest_, a framework for easily building simple and scalable tests.
12+
After you have set up to `develop locally`_, run the following commands to make sure the testing environment is ready: ::
13+
14+
$ pytest
15+
16+
You will get a readout of the `users` app that has already been set up with tests. If you do not want to run the `pytest` on the entire project, you can target a particular app by typing in its location: ::
17+
18+
$ pytest <path-to-app-in-project/app>
19+
20+
If you set up your project to `develop locally with docker`_, run the following command: ::
21+
22+
$ docker-compose -f local.yml run django pytest
23+
24+
Targetting particular apps for testing in ``docker`` follows a similar pattern as previously shown above.
25+
26+
Coverage
27+
--------
28+
29+
You should build your tests to provide the highest level of **code coverage**. You can run the ``pytest`` with code ``coverage`` by typing in the following command: ::
30+
31+
$ docker-compose -f local.yml run django coverage run -m pytest
32+
33+
Once the tests are complete, in order to see the code coverage, run the following command: ::
34+
35+
$ docker-compose -f local.yml run django coverage report
36+
37+
.. note::
38+
39+
At the root of the project folder, you will find the `pytest.ini` file. You can use this to customize_ the ``pytest`` to your liking.
40+
41+
There is also the `.coveragerc`. This is the configuration file for the ``coverage`` tool. You can find out more about `configuring`_ ``coverage``.
42+
43+
.. seealso::
44+
45+
For unit tests, run: ::
46+
47+
$ python manage.py test
48+
49+
Since this is a fresh install, and there are no tests built using the Python `unittest`_ library yet, you should get feedback that says there were no tests carried out.
50+
51+
.. _Pytest: https://docs.pytest.org/en/latest/example/simple.html
52+
.. _develop locally: ../developing-locally.rst
53+
.. _develop locally with docker: ..../developing-locally-docker.rst
54+
.. _customize: https://docs.pytest.org/en/latest/customize.html
55+
.. _unittest: https://docs.python.org/3/library/unittest.html#module-unittest
56+
.. _configuring: https://coverage.readthedocs.io/en/v4.5.x/config.html

0 commit comments

Comments
 (0)