taiga-back/tests/unit/test_utils.py

16 lines
522 B
Python

import django_sites as sites
from taiga.base.utils.urls import get_absolute_url, is_absolute_url, build_url
def test_is_absolute_url():
assert is_absolute_url("http://domain/path")
assert is_absolute_url("https://domain/path")
assert not is_absolute_url("://domain/path")
def test_get_absolute_url():
site = sites.get_current()
assert get_absolute_url("http://domain/path") == "http://domain/path"
assert get_absolute_url("/path") == build_url("/path", domain=site.domain, scheme=site.scheme)