Skip to content

Latest commit

 

History

History
67 lines (38 loc) · 1.99 KB

File metadata and controls

67 lines (38 loc) · 1.99 KB

Contributing to DjraphQL

Virtual environments

Create virtual environments to run the Django app (assumes python --version prints Python 2.7.17):

  • virtualenv .venv-py2
  • virtualenv -p python3 .venv-py3

Activate one of them

In VSCode, it may be necessary to cmd+shift+p, Python: Select interpreter to set the correct venv for the debugger.

  • source .venv-py3/bin/activate

Install dependencies. Leave Django out of requirements and explicitly install it, so that we can easily test across multiple versions.

  • pip install -r requirements.txt django==3.2.12
  • pip install -r requirements-docs.txt

Run tests

  • python ./manage.py test

Run tests w/ test coverage metrics

coverage run --source djraphql -m pytest
coverage report -m

How to unit-test

Nearly all unit-tests reside in the sample_music_app app, under the tests folder. This allows for directly testing the API generated by DjraphQL by building a schema based on the Django models defined in app.

Low-level unit-tests that make assumptions about implementation are not encouraged. Rather, write surface-level unit-tests that exercise a specific feature, behavior, or bug being fixed. This allows us to confidently and more easily refactor the underlying implementation without the burden of unnecessarily broken tests.

Remove unused imports

  • pip install autoflake
  • autoflake --in-place --remove-all-unused-imports --ignore-init-module-imports ./**/*.py

Build for distribution

See tutorial here.

Install setuptools

  • pip install --user --upgrade setuptools wheel twine

Bump the version

  • In setup.py, update the VERSION number

Package the library

  • python setup.py sdist bdist_wheel

Upload to PyPi

  • twine upload dist/djraphql-x.x.x.tar.gz
    • Enter __token__ for the user, then a valid PyPi token as the password

Build the docs

  • pip install -r requirements-docs.txt
  • cd docsrc && make html