aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/tests/test_models.py
blob: 460d3d73b80f8370e607f5db14b8ebab3397076b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import pytest
from slugify import slugify

from ..models import Organisation, Address

pytestmark = pytest.mark.django_db


def test_organisation_get_absolute_url(org: Organisation):
    slug = slugify(org.name)
    assert org.get_absolute_url() == f"/organisations/{slug}/"


def test_create_organisation(addr: Address):
    Organisation(name="Big Bad OES Corporation", address=addr).save()
    assert Organisation.objects.get(name="Big Bad OES Corporation")
    assert Organisation.objects.get(name="Big Bad OES Corporation").address.type.descriptor == "Primary Address"