|
1 | 1 | =========== |
2 | 2 | Development |
3 | 3 | =========== |
| 4 | +If you want to hack on this little library clone it via git |
| 5 | + |
| 6 | +.. code-block:: bash |
| 7 | +
|
| 8 | + git clone https://github.com/Corvan/mailpit-api-client.git |
| 9 | +
|
| 10 | +or |
| 11 | + |
| 12 | +.. code-block:: bash |
| 13 | +
|
| 14 | + git clone git@github.com:Corvan/mailpit-api-client.git |
| 15 | +
|
| 16 | +Of course you can fork it first on GitHub. |
| 17 | +Then you are easily able to open PRs, which is the preferred way of contributing code. |
4 | 18 |
|
5 | 19 | -------------------- |
6 | 20 | Install dependencies |
7 | 21 | -------------------- |
| 22 | +It is recommended to use a virtual environment, in order to separate the dependencies |
| 23 | +for this project from dependencies of other projects. |
| 24 | +There are several tools out there to manage virtual environments, so please consult the |
| 25 | +respective documentantion if you're not using ``venv`` or ``poetry`` |
| 26 | + |
| 27 | +If you want to run the tests :ref:`for all possible versions of Python <invoke-tasks>` |
| 28 | +you have to install `Docker Engine <https://docs.docker.com/engine/install/>`_, and the |
| 29 | +`Docker Compose plugin <https://docs.docker.com/compose/install/linux/>`_ on Linux. |
| 30 | +Or you install `Docker Desktop <https://docs.docker.com/get-docker/>`_ on other |
| 31 | +operating system and on Linux. |
| 32 | + |
| 33 | +___ |
| 34 | +pip |
| 35 | +___ |
| 36 | + |
| 37 | +in order to install the Python dependencies enter the directory of your just cloned |
| 38 | +git repository, activate your virtual environment and type: |
8 | 39 |
|
9 | 40 | .. code-block:: python |
10 | 41 |
|
11 | 42 | pip install -e ".[docs,test,pytest,build]" |
12 | 43 |
|
| 44 | +
|
| 45 | +Now you can start hacking. |
| 46 | + |
| 47 | +______ |
| 48 | +poetry |
| 49 | +______ |
| 50 | +If you want to use poetry as the manager for your virtual environment, install it if |
| 51 | +necessary and run |
| 52 | + |
| 53 | +.. code-block:: bash |
| 54 | +
|
| 55 | + poetry update |
| 56 | +
|
| 57 | +inside the project's directory. |
| 58 | + |
| 59 | +In order to run the :ref:`invoke-tasks` you have to prefix all commands given there with |
| 60 | + |
| 61 | +.. code-block:: bash |
| 62 | +
|
| 63 | + poetry run |
| 64 | +
|
| 65 | +so running the Invoke task of unittests you have to type |
| 66 | + |
| 67 | +.. code-block:: bash |
| 68 | +
|
| 69 | + poetry run invoke tests.unit |
| 70 | +
|
| 71 | +----------------- |
| 72 | +Running the tests |
| 73 | +----------------- |
| 74 | +This project uses `pytest <https://pytest.org>`_ as testing framework. |
| 75 | +Even the `unittest <https://docs.python.org/3/library/unittest.html>`_ parts are tested |
| 76 | +themselves with ``pytest``. |
| 77 | + |
| 78 | +There are two kinds of tests in this project: |
| 79 | + |
| 80 | +================== ================================================================================================= |
| 81 | +test type description |
| 82 | +================== ================================================================================================= |
| 83 | +unit tests unit tests are tests that check if a functionality works isolated from everything else |
| 84 | +integration tests integration tests are tests that include dependencies, and check if functionalities work together |
| 85 | +================== ================================================================================================= |
| 86 | + |
| 87 | +You can run the tests locally, but then you have to provide a `running Mailpit by |
| 88 | +yourself <https://github.com/axllent/mailpit/blob/develop/README.md>`_ for running the |
| 89 | +integration tests. |
| 90 | + |
| 91 | +.. _invoke-tasks: |
| 92 | + |
| 93 | +____________ |
| 94 | +Invoke tasks |
| 95 | +____________ |
| 96 | + |
| 97 | +In order to run the tests inside Docker containers, there are |
| 98 | +`Invoke <https://www.pyinvoke.org>`_ tasks that use Docker Compose to set-up all the |
| 99 | +necessary containers and run the checks and tests in them afterwards. |
| 100 | +At the end things are cleaned up again. |
| 101 | + |
| 102 | +.. code-block:: bash |
| 103 | +
|
| 104 | + $ invoke -l |
| 105 | +
|
| 106 | + Available tasks: |
| 107 | +
|
| 108 | + tests.checks |
| 109 | + tests.integration |
| 110 | + tests.unit |
| 111 | +
|
| 112 | +There are some more tasks, but you can concentrate on those three. |
| 113 | + |
| 114 | +================= =============================================================================================== |
| 115 | +task description |
| 116 | +================= =============================================================================================== |
| 117 | +tests.checks runs code checks, like black (code formatting), ruff (linting), and mypy (static code analysis) |
| 118 | +tests.integration runs the integration tests |
| 119 | +tests.unit runs the unit tests |
| 120 | +================= =============================================================================================== |
| 121 | + |
| 122 | +To run a task, simply type |
| 123 | + |
| 124 | +.. code-block:: bash |
| 125 | +
|
| 126 | + invoke <task> |
| 127 | +
|
| 128 | +It is also possible to run multiple tasks at once |
| 129 | + |
| 130 | +.. code-block:: bash |
| 131 | +
|
| 132 | + invoke tests.checks tests.unit tests.integration |
| 133 | +
|
| 134 | +For running the tests all the logging outputs are set to debug. |
| 135 | +So running them will produce *a lot* of output, but you will want to know why things |
| 136 | +go wrong. |
| 137 | +If you want to reduce the amount, have a look at :file:`pyproject.toml` |
| 138 | + |
| 139 | +----------------------- |
| 140 | +Build the documentation |
| 141 | +----------------------- |
| 142 | + |
13 | 143 | .. code-block:: bash |
14 | 144 |
|
| 145 | +cd docs |
15 | 146 | make clean |
16 | 147 | sphinx-apidoc -d 4 -eM -f -o generated ../mailpit |
17 | 148 | make html |
0 commit comments