Skip to main content

Better fixtures for django

Project description

GitHub Workflow Status https://img.shields.io/pypi/v/pytest-tipsi-django.svg

Installation

$ pip install pytest-tipsi-django

Features

Default django test settings

  • if you run pytest after install pytest-tipsi-django, Configuration already has django settings.CACHE[‘default’]

  • of course if you has Custom django settings, this settings to below are ignored.

DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
BROKER_BACKEND = 'memory'
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'TIMEOUT': 60 * 15
    }
}

API helpers

There is built-in fixture anonymouse_client and you can create helpers for your users wrapping them with pytest_tipsi_django.client_fixtures.UserWrapper.

It provides you usefull helpers for all request types.

expected parameter in <METHOD>_json is very usefull to prevent tedious status code checks.

from pytest_tipsi_django.client_fixtures import UserWrapper

def test_00_anonymous(anonymous_client, some_url):
    query_params = {'filter': 'query'}
    body = {'param1': 'param''}

    anonymous_client.get_json(some_url, query_params, expected=401)
    anonymous_client.post_json(some_url, body, expected=403)

    json_response = anonymous_client.patch_json(some_url, body)
    anonymous_client.put_json(some_url, body)
    anonymous_client.delete_json(some_url)


@pytest.fixture
def user_client(user_object):
    yield UserWrapper(user_client)

def test_01_authorized(user_client, some_url):
    resp_json = user_client.get_json(some_url, expected=200)

Other fixtures

  • debug_db_queries - prints performed queries

License

pytest-tipsi-django is distributed under the terms of the MIT License.

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

pytest_tipsi_django-2.8.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

pytest_tipsi_django-2.8.0-py2.py3-none-any.whl (9.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest_tipsi_django-2.8.0.tar.gz.

File metadata

  • Download URL: pytest_tipsi_django-2.8.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for pytest_tipsi_django-2.8.0.tar.gz
Algorithm Hash digest
SHA256 97c89981fd44fb145efb485f61c35ff9c029929f7bc94a6946fd22ca05783905
MD5 6698378ec500762b501b489c1d9faba1
BLAKE2b-256 b02ba7effbc09ed2d728ac8c6cdef07face70385098083a770d2855349f5a138

See more details on using hashes here.

File details

Details for the file pytest_tipsi_django-2.8.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_tipsi_django-2.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8ba8dc35d0d6d1a040a315b9c98214ec494a8ccf7fbc25aab5d36160aec658e7
MD5 b70c2d5a2e46a7491e2372d93e4bef72
BLAKE2b-256 085536049c05d622fa092f4b8a168d200658fd1afe5b72cc8987c4d92f171001

See more details on using hashes here.

Supported by

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