|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Contributions are encouraged! Please use the issue page to submit feature requests or bug reports. Issues with attached PRs will be given priority and have a much higher likelihood of acceptance. Please also open an issue and associate it with any submitted PRs. That said, the aim is to keep this library as lightweight as possible. Only features with broad based use cases will be considered. |
| 4 | + |
| 5 | +We are actively seeking additional maintainers. If you're interested, please contact [me](https://github.com/bckohan). |
| 6 | + |
| 7 | + |
| 8 | +## Installation |
| 9 | + |
| 10 | +`django-enum` uses [Poetry](https://python-poetry.org/) for environment, package and dependency management: |
| 11 | + |
| 12 | +```console |
| 13 | + poetry install -E all --with psycopg3 |
| 14 | +``` |
| 15 | + |
| 16 | +## Documentation |
| 17 | + |
| 18 | +`django-enum` documentation is generated using [Sphinx](https://www.sphinx-doc.org). Any new feature PRs must provide updated documentation for the features added. To build the docs run: |
| 19 | + |
| 20 | +```console |
| 21 | + cd ./doc |
| 22 | + poetry run make html |
| 23 | +``` |
| 24 | + |
| 25 | +## Static Analysis |
| 26 | + |
| 27 | +`django-enum` uses [ruff](https://docs.astral.sh/ruff) for python linting and formatting. [mypy](http://mypy-lang.org) is used for static type checking. Before any PR is accepted the following must be run, and static analysis tools should not produce any errors or warnings. Disabling certain errors or warnings where justified is acceptable: |
| 28 | + |
| 29 | +```console |
| 30 | + ./check.sh |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +## Running Tests |
| 35 | + |
| 36 | +`django-enum` uses [pytest](https://docs.pytest.org/) to define and run tests. All the tests are housed in tests/tests.py. Before a PR is accepted, all tests must be passing and the code coverage must be at 100%. A small number of exempted error handling branches are acceptable. |
| 37 | + |
| 38 | +To run the full suite: |
| 39 | + |
| 40 | +```console |
| 41 | + poetry run pytest |
| 42 | +``` |
| 43 | + |
| 44 | +To run a single test, or group of tests in a class: |
| 45 | + |
| 46 | +```console |
| 47 | + poetry run pytest <path_to_tests_file>::ClassName::FunctionName |
| 48 | +``` |
| 49 | + |
| 50 | +For instance to run all tests in TestDjangoEnums, and then just the |
| 51 | +test_properties_and_symmetry test you would do: |
| 52 | + |
| 53 | +```console |
| 54 | + poetry run pytest tests/tests.py::TestDjangoEnums |
| 55 | + poetry run pytest tests/tests.py::TestDjangoEnums::test_properties_and_symmetry |
| 56 | +``` |
| 57 | + |
| 58 | +## RDBMS |
| 59 | + |
| 60 | +By default, the tests will run against postgresql so in order to run the tests you will need to have a postgresql server running that is accessible to the default postgres user with no password. The test suite can be run against any RDBMS supported by Django. Just set the RDBMS environment variable to one of: |
| 61 | + |
| 62 | + * postgres |
| 63 | + * sqlite |
| 64 | + * mysql |
| 65 | + * mariadb |
| 66 | + * oracle |
| 67 | + |
| 68 | +The settings for each RDBMS can be found in tests/settings.py. The database settings can be altered via environment variables that are referenced therein. The default settings are designed to work out of the box with the official docker images for each RDBMS. Reference the github actions workflow for an example of how to run the tests against each RDBMS using docker containers. |
| 69 | + |
| 70 | +Additional dependency groups will need to be installed for some RDBMS: |
| 71 | + |
| 72 | +```console |
| 73 | + |
| 74 | + # for postgres using psycopg3 |
| 75 | + poetry install -E all --with psycopg3 |
| 76 | + |
| 77 | + # for postgres using psycopg2 |
| 78 | + poetry install -E all --with psycopg2 |
| 79 | + |
| 80 | + # for mysql or mariadb |
| 81 | + poetry install -E all --with mysql |
| 82 | + |
| 83 | + # for oracle |
| 84 | + poetry install -E all --with oracle |
| 85 | +``` |
0 commit comments