File: test_urls.py

package info (click to toggle)
python-django-structlog 9.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,004 kB
  • sloc: python: 3,509; sh: 206; javascript: 79; makefile: 19
file content (32 lines) | stat: -rw-r--r-- 964 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest
from django.conf import settings
from django.urls import resolve, reverse

pytestmark = pytest.mark.django_db


def test_detail(user: settings.AUTH_USER_MODEL):
    route = f"/users/{user.username}/"
    assert reverse("users:detail", kwargs={"username": user.username}) == route
    assert resolve(route).view_name == "users:detail"


def test_detail_username_with_dot():
    route = "/users/foo.bar/"
    assert reverse("users:detail", kwargs={"username": "foo.bar"}) == route
    assert resolve(route).view_name == "users:detail"


def test_list():
    assert reverse("users:list") == "/users/"
    assert resolve("/users/").view_name == "users:list"


def test_update():
    assert reverse("users:update") == "/users/~update/"
    assert resolve("/users/~update/").view_name == "users:update"


def test_redirect():
    assert reverse("users:redirect") == "/users/~redirect/"
    assert resolve("/users/~redirect/").view_name == "users:redirect"