Skip to main content

Plugin to run Django with the Hitch testing framework.

Project description

HitchDjango

HitchDjango is a plugin for the Hitch test framework that lets you run and interact with Django as part of a test.

When the plugin starts Django, before running runserver, it will:

  • Check the version and fail if it is different to what is specified.

  • Run migrations (using manage.py migrate).

  • Get the URL using localhost + the specified port and put it in sites.site.

  • Install all specified Django fixtures.

Currently HitchDjango runs only on Django 1.8 and above. Please raise a ticket if you need an earlier version.

Use with Hitch

Install like so:

$ hitch install hitchdjango
# Service definition in engine's setUp:
self.services['Django'] = hitchdjango.DjangoService(
    version="1.8",                                              # Mandatory
    python="{}/venv/bin/python".format(PROJECT_DIRECTORY),      # Mandatory
    managepy=None,                                              # Optional full path to manage.py (default: None, assumes in project directory)
    django_fixtures=['fixture1.json',],                         # Optional (default: None)
    port=18080,                                                 # Optional (default: 18080)
    settings="remindme.settings",                               # Optional (default: settings)
    needs=[self.services['Postgres'], ]                         # Optional (default: no prerequisites)
)


# Interact during the test:
>>> self.services['Django'].manage("help").run()
[ Prints help ]

>>> self.services['Django'].url()
http://127.0.0.1:18080/

>>> self.services['Django'].savefixture("fixtures/database_current_state.json").run()
[ Saves fixture ]

See this service in action at the DjangoRemindMe project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hitchdjango-0.2.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file hitchdjango-0.2.tar.gz.

File metadata

  • Download URL: hitchdjango-0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hitchdjango-0.2.tar.gz
Algorithm Hash digest
SHA256 189d8cfa4f335d564840ea6c403dbb76c90c6e975c127c357586fd85ee34801b
MD5 cda75b8ff37f0c418ac853cfbd74dbf4
BLAKE2b-256 a0f8b44bac68aaf6d17c9df6d4a4b13ad9953695c47ff98071213c8f17c26148

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page