I 💛 the Django Girls Tutorial. After following it, I continued the fun by:
- Adding Tests
- Setting up Continuous Integration with circleci
- Setting up Code Climate
- Install the version of Python the .tool-versions file.
- You may want to use asdf for this purpose.
- Make sure you have GNU Make installed on your machine.
- A Makefile was added to the project to simplify some tasks.
- The project uses pipenv to manage the Python dependencies and facilitate the workflow when working with a virtualenv. You'll need to install pipenv before getting started:
brew install pipenv
- Setup dev environment:
make dev_setup
- Make sure things are healthy by running the tests:
make test
- Start the server:
make runserver
All the tests that are run as part of CI are in the tests folder, and you can run them locally with:
python manage.py test tests
ℹ️ Additionally, you can run: make test
The execution includes E2E Functional Tests that run on Firefox in headless mode.
E2E / UI tests that do not run in headless mode, can be run separately, see the E2E Tests section.
You can pass the module or test case:
python manage.py test <module_pattern>
For example, to run all the tests in the test_models
module:
python manage.py test tests.test_models
And you can also use the --pattern
or -p
argument. For example:
python manage.py test --pattern="*_forms.py"
python manage.py test -p "*_forms.py"
You can get more details about the test execution by passing the argument --verbosity
or -v
. For the value you can choose from: 0, 1, 2, 3
.
For example, to pass verbosity of 2:
python manage.py test tests -v 2
coverage run manage.py test tests
coverage html -d coverage-report
🔎 It is also possible to run a single E2E test by using the options described here.
E2E Tests that do not run in headless mode are currently run separately from the main test suite and can be run with:
python manage.py test e2e.local
E2E tests by default run in headless mode, this means that if you want to troubleshoot via the browser and the driver doing its magic, you will need to modify the test you would like to troubleshoot and change:
firefox_options.headless = True
to
firefox_options.headless = False
Remote E2E Tests - tests that run on the cloud - are setup to run on Sauce Labs ⚡.
- A username and API Key is needed to run the tests on the Sauce Labs Testing Cloud.
Tests that run on the cloud can be run with:
python manage.py test e2e.remote
A visual demo of the blog, implemented with SeleniumBase can be run with:
sh demo.sh
ℹ️ Make sure that your development server is already started, before running the demo.
- Install geckodriver - The Web Driver for Firefox.
Continuous Integration (CI) is managed with the help of CircleCI.
Every time a PR is opened all tests inside tests are run. Passing tests are required to merge a PR to master.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
The tutorial that was followed for the creation of this blog is attributed to Django Girls and it can be found here.