Skip to content

A blog written in Django and based on the Django Girls Tutorial Blog.

License

Notifications You must be signed in to change notification settings

eliflores/mignonnesaurus-blog

Repository files navigation

Mignonnesaurus Blog

CircleCI Test Coverage Maintainability License: CC BY 4.0 Conventional Commits

Introduction

I 💛 the Django Girls Tutorial. After following it, I continued the fun by:

Getting started

How to run the project locally?

  1. Install the version of Python the .tool-versions file.
  • You may want to use asdf for this purpose.
  1. Make sure you have GNU Make installed on your machine.
  • A Makefile was added to the project to simplify some tasks.
  1. 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
  1. Setup dev environment:
make dev_setup
  1. Make sure things are healthy by running the tests:
make test
  1. Start the server:
make runserver

How to run tests?

Test suite

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.

Single test case(s)

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"

Modify the verbosity level

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

Code coverage

coverage run manage.py test tests

Coverage report

coverage html -d coverage-report

E2E Tests

🔎 It is also possible to run a single E2E test by using the options described here.

On a local machine 💻

Running E2E Tests

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

Troubleshooting E2E Tests

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

On a remote machine ☁️

Remote E2E Tests - tests that run on the cloud - are setup to run on Sauce Labs ⚡.

Pre-requirements

  • A username and API Key is needed to run the tests on the Sauce Labs Testing Cloud.

Running E2E Tests

Tests that run on the cloud can be run with:

python manage.py test e2e.remote

Demos

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.

Pre-requirements

Continuous Integration

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.


CC BY-SA 4.0

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.

CC BY-SA 4.0