Skip to content

eliflores/mignonnesaurus-blog

Repository files navigation

Mignonnesaurus Blog

CircleCI Code Coverage Maintainability License: CC BY 4.0 Conventional Commits

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

  • Adding Tests
  • Setting up Continuous Integration with circleci
  • Setting up Qlty

Table of Contents

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.

  2. Setup dev environment:

make dev_setup
  1. Make sure things are healthy by running the tests:
make test
  1. Start the server:
make runserver

Testing

The tests that are run as part of CI are:

  • tests.forms
  • tests.models
  • tests.views
  • tests.functional: these are run as E2E tests with Selenium and Firefox in headless mode.

You can run all of these tests with: make test or with the following command:

python manage.py test tests.forms tests.models tests.views tests.functional

Running a single test

You can pass the module or test case:

python manage.py test <module_pattern> 

For example, to run all the tests in the models module:

python manage.py test tests.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.functional -v 2

Code coverage

make test_coverage

Coverage report

coverage html -d coverage-report

E2E Tests

E2E Tests that open a visible browser are currently run separately from the rest of the tests. To run them, make sure you have Firefox installed and run:

make test_e2e

Troubleshooting E2E Tests

E2E tests use the shared Firefox WebDriver factory in tests/webdriver.py. If Firefox is installed in a non-standard path, set FIREFOX_BINARY before running the tests.

export FIREFOX_BINARY=/path/to/firefox

Demos

A visual demo of the blog, implemented with SeleniumBase can be run with:

make rundemo

ℹ️ The development server needs to already be running and a superuser needs to also exist with credentials that need to be exposed as environment variables:

export MY_BLOG_USERNAME=myusername
export MY_BLOG_PASSWORD=mypassword

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors