django-test-urls


Namedjango-test-urls JSON
Version 0.3.0 PyPI version JSON
download
home_page
SummaryA package used to test URL dispatching in Django applications.
upload_time2022-12-09 19:45:34
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT
keywords django url url dispatch test testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ##############################################################################
django-test-urls 0.3.0
##############################################################################

.. image:: https://github.com/alanverresen/django-test-urls/actions/workflows/build.yml/badge.svg
    :target: https://github.com/alanverresen/django-test-urls/actions/workflows/build.yml
    :alt: Build Status

.. image:: https://github.com/alanverresen/django-test-urls/actions/workflows/tests.yml/badge.svg
    :target: https://github.com/alanverresen/django-test-urls/actions/workflows/tests.yml
    :alt: Tests Status

.. image:: https://readthedocs.org/projects/django-test-urls/badge/?version=latest
    :target: https://django-test-urls.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

This small Python package defines a small set of functions that can be used
to test the mapping of URLs in a Django application:

* whether a URL is mapped correctly to a view
* whether a URL is not mapped to a view
* whether arguments are captured as expected


==============================================================================
Installation
==============================================================================

This package is available on the Python Package Index (PyPI), so you can
install this package using `pip`:

.. code-block:: sh

    $ python -m pip install django-test-urls


==============================================================================
Usage
==============================================================================

The fictional app that is being tested in this example contains a view that
lists every article that has been released in a given month. The following
URL pattern is used to map URLs to the aforementioned view, and captures two
values, `year` and `month`, to pass along.

.. code-block:: python

    # urls.py
    urlpatterns = [
        ...
        path('articles/<int:year>/<int:month>/', views.month_archive),
        ...
    ]


The following test verifies that an example URL is mapped correctly to the
right view and that values are captured correctly.

.. code-block:: python

    # test_urls.py
    from django_test_urls import resolves_to_view
    from django_test_urls import resolves_to_arguments
    from my_app import views


    def test_monthly_archive():
        assert resolves_to_view("articles/2022/11/", views.month_archive)
        assert resolves_to_arguments("articles/2022/11", (), {"year": 2022, "month": 11})


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-test-urls",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "Django,URL,URL dispatch,test,testing",
    "author": "",
    "author_email": "Alan Verresen <dev@alanverresen.com>",
    "download_url": "https://files.pythonhosted.org/packages/65/97/b72bbded96c569fcc98f525af653ac0aa18b1c1f83db764898e7f6e6525b/django-test-urls-0.3.0.tar.gz",
    "platform": null,
    "description": "##############################################################################\ndjango-test-urls 0.3.0\n##############################################################################\n\n.. image:: https://github.com/alanverresen/django-test-urls/actions/workflows/build.yml/badge.svg\n    :target: https://github.com/alanverresen/django-test-urls/actions/workflows/build.yml\n    :alt: Build Status\n\n.. image:: https://github.com/alanverresen/django-test-urls/actions/workflows/tests.yml/badge.svg\n    :target: https://github.com/alanverresen/django-test-urls/actions/workflows/tests.yml\n    :alt: Tests Status\n\n.. image:: https://readthedocs.org/projects/django-test-urls/badge/?version=latest\n    :target: https://django-test-urls.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\nThis small Python package defines a small set of functions that can be used\nto test the mapping of URLs in a Django application:\n\n* whether a URL is mapped correctly to a view\n* whether a URL is not mapped to a view\n* whether arguments are captured as expected\n\n\n==============================================================================\nInstallation\n==============================================================================\n\nThis package is available on the Python Package Index (PyPI), so you can\ninstall this package using `pip`:\n\n.. code-block:: sh\n\n    $ python -m pip install django-test-urls\n\n\n==============================================================================\nUsage\n==============================================================================\n\nThe fictional app that is being tested in this example contains a view that\nlists every article that has been released in a given month. The following\nURL pattern is used to map URLs to the aforementioned view, and captures two\nvalues, `year` and `month`, to pass along.\n\n.. code-block:: python\n\n    # urls.py\n    urlpatterns = [\n        ...\n        path('articles/<int:year>/<int:month>/', views.month_archive),\n        ...\n    ]\n\n\nThe following test verifies that an example URL is mapped correctly to the\nright view and that values are captured correctly.\n\n.. code-block:: python\n\n    # test_urls.py\n    from django_test_urls import resolves_to_view\n    from django_test_urls import resolves_to_arguments\n    from my_app import views\n\n\n    def test_monthly_archive():\n        assert resolves_to_view(\"articles/2022/11/\", views.month_archive)\n        assert resolves_to_arguments(\"articles/2022/11\", (), {\"year\": 2022, \"month\": 11})\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package used to test URL dispatching in Django applications.",
    "version": "0.3.0",
    "split_keywords": [
        "django",
        "url",
        "url dispatch",
        "test",
        "testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "f14ffefb3c89c006eb13e3fe3db0c87e",
                "sha256": "7db81e80f1a81fcb0f87007cb53885e1a1362d8f2ca57c0b75411f2beb240ff5"
            },
            "downloads": -1,
            "filename": "django_test_urls-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f14ffefb3c89c006eb13e3fe3db0c87e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5872,
            "upload_time": "2022-12-09T19:45:32",
            "upload_time_iso_8601": "2022-12-09T19:45:32.013806Z",
            "url": "https://files.pythonhosted.org/packages/22/f0/4d9c5b633279503ae850fa943259d2eee5e612ce68cd7a14d2b6b3f63d3b/django_test_urls-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "ad1ef9155686641787d7909ec67c7302",
                "sha256": "9d4928e28c2204fb174535a4eb925f44971ee9a7d7b1e2d26a77f42af05a8dab"
            },
            "downloads": -1,
            "filename": "django-test-urls-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ad1ef9155686641787d7909ec67c7302",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5242,
            "upload_time": "2022-12-09T19:45:34",
            "upload_time_iso_8601": "2022-12-09T19:45:34.169583Z",
            "url": "https://files.pythonhosted.org/packages/65/97/b72bbded96c569fcc98f525af653ac0aa18b1c1f83db764898e7f6e6525b/django-test-urls-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-09 19:45:34",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "django-test-urls"
}
        
Elapsed time: 0.01752s