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 for Code Quality and Code Coverage
- Setting up a delivery pipeline to run the blog in a staging and production environment in Heroku.
- Create a virtual env
python -m venv venv
- Active the virtual env:
source venv/bin/activate
- Start the web server:
python manage.py runserver localhost:8000
- Development server will run at:
http://localhost:8000/
The test suite currently includes unit and integration tests and can be run with:
python runtests.py
It does not include E2E / UI tests, they 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.
- Install geckodriver - The Web Driver for Firefox.
brew install geckodriver
E2E Tests are currently run separately from the main test suite and can be run with:
python manage.py test e2e.local
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
Demo tests are E2E selenium tests that run with SeleniumBase to provide a visual blog tour of this project.
- Install geckodriver - The Web Driver for Firefox.
brew install geckodriver
./tour.sh
Continuous Integration (CI) is managed with the help of CircleCI.
Every time a PR is opened all tests - except E2E Functional tests - are run. Passing tests are required to merge a PR to master.
The application runs in Heroku.
There are 2 different environments:
Deployment is managed with the help of CircleCI and after a PR is merged, the change is automagically deployed to the staging environment.
Once changes are verified in staging, they can be promoted to production using Heroku Pipelines.
Here is how the UI to promote changes looks like in Heroku:
Heroku has a Review Apps feature that could be used if you would like to see or test a feature or a fix under development. You can create an ad-hoc app for a PR that is open, review the changes and then delete the app.
Here is how Review Apps UI looks like in Heroku: