File: test_urlresolvers.py

package info (click to toggle)
python-django-pgschemas 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 848 kB
  • sloc: python: 3,887; makefile: 33; sh: 10; sql: 2
file content (32 lines) | stat: -rw-r--r-- 824 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
from django.conf import settings
from django.urls import reverse

from django_pgschemas.routing.info import DomainInfo
from django_pgschemas.routing.urlresolvers import get_dynamic_tenant_prefixed_urlconf


def test_no_tenant():
    url = reverse("profile")

    assert url == "/profile/"


def test_tenant_with_no_folder(tenant1):
    with tenant1:
        url = reverse("profile")

    assert url == "/profile/"


def test_tenant_with_folder(tenant1):
    tenant1.routing = DomainInfo(domain="irrelevant", folder="tenant1")

    dynamic_path = settings.ROOT_URLCONF + "_dynamically_tenant_prefixed"
    urlconf = get_dynamic_tenant_prefixed_urlconf(settings.ROOT_URLCONF, dynamic_path)

    with tenant1:
        url = reverse("profile", urlconf=urlconf)

    tenant1.routing = None

    assert url == "/tenant1/profile/"