aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/conftest.py3
-rw-r--r--ctrack/organisations/tests/factories.py25
-rw-r--r--ctrack/organisations/tests/test_models.py10
-rw-r--r--ctrack/users/tests/factories.py33
4 files changed, 31 insertions, 40 deletions
diff --git a/ctrack/conftest.py b/ctrack/conftest.py
index d9755f7..a3ed183 100644
--- a/ctrack/conftest.py
+++ b/ctrack/conftest.py
@@ -5,9 +5,8 @@ from ctrack.users.models import User
from ctrack.organisations.models import Organisation, Address
from ctrack.users.tests.factories import (
UserFactory,
- OrganisationFactory,
- AddressFactory,
)
+from ctrack.organisations.tests.factories import OrganisationFactory, AddressFactory
@pytest.fixture(autouse=True)
diff --git a/ctrack/organisations/tests/factories.py b/ctrack/organisations/tests/factories.py
index aaca669..99a4bb3 100644
--- a/ctrack/organisations/tests/factories.py
+++ b/ctrack/organisations/tests/factories.py
@@ -5,7 +5,7 @@ import factory
from django.contrib.auth import get_user_model
from factory import DjangoModelFactory, Faker, SubFactory, post_generation
-from ctrack.organisations.models import Mode, Organisation, Person, Role, Submode
+from ctrack.organisations.models import Mode, Organisation, Person, Role, Submode, Address, AddressType
User = get_user_model()
@@ -112,3 +112,26 @@ class PersonFactory(DjangoModelFactory):
date_ended = Faker("date_this_year")
predecessor = SubFactory("ctrack.organisations.tests.factories.PersonFactory")
comments = "Yaa!"
+
+
+class AddressFactory(DjangoModelFactory):
+ type = SubFactory("ctrack.organisations.tests.factories.AddressTypeFactory")
+ organisation = SubFactory(OrganisationFactory)
+ line1 = Faker("secondary_address", locale="en_GB")
+ line2 = Faker("street_name", locale="en_GB")
+ line3 = Faker("secondary_address", locale="en_GB")
+ city = Faker("city", locale="en_GB")
+ county = Faker("lexify", locale="en_GB", text="??????", letters="aeioutzyj")
+ postcode = Faker("postcode", locale="en_GB")
+ country = Faker("country")
+ other_details = Faker("lexify", locale="en_GB", text="??????", letters="aeioutzyj")
+
+ class Meta:
+ model = Address
+
+
+class AddressTypeFactory(DjangoModelFactory):
+ descriptor = "Primary Address"
+
+ class Meta:
+ model = AddressType
diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py
index cb3b9af..740b782 100644
--- a/ctrack/organisations/tests/test_models.py
+++ b/ctrack/organisations/tests/test_models.py
@@ -1,12 +1,12 @@
import pytest
from slugify import slugify
-from ..models import Organisation, Address
+from ctrack.organisations.models import Organisation
pytestmark = pytest.mark.django_db
-def test_organisation_get_absolute_url(org: Organisation):
+def test_organisation_get_absolute_url(org):
slug = slugify(org.name)
assert org.get_absolute_url() == f"/organisations/{slug}/"
@@ -17,7 +17,7 @@ def test_create_organisation():
assert Organisation.objects.get(name="Big Bad OES Corporation")
-def test_delete_organisation(org: Organisation):
+def test_delete_organisation(org):
orgs = Organisation.objects.all()
assert org in orgs
Organisation.delete(org)
@@ -25,13 +25,13 @@ def test_delete_organisation(org: Organisation):
assert Organisation.objects.count() == 0
-def test_update_organisation(org: Organisation):
+def test_update_organisation(org):
# Change the name of the organisation
org.name = "Tonkers Ltd"
org.save()
assert org.name == "Tonkers Ltd"
-def test_new_address(addr: Address):
+def test_new_address(addr):
# The address "has" an organisation
assert addr.organisation.name
diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py
index 53584b7..b4ddad0 100644
--- a/ctrack/users/tests/factories.py
+++ b/ctrack/users/tests/factories.py
@@ -1,38 +1,7 @@
from typing import Any, Sequence
from django.contrib.auth import get_user_model
-from ctrack.organisations.models import Organisation, Address, AddressType
-from factory import DjangoModelFactory, Faker, post_generation, SubFactory
-
-
-class AddressTypeFactory(DjangoModelFactory):
- descriptor = "Primary Address"
-
- class Meta:
- model = AddressType
-
-
-class OrganisationFactory(DjangoModelFactory):
- name = Faker("company", locale="en_GB")
-
- class Meta:
- model = Organisation
-
-
-class AddressFactory(DjangoModelFactory):
- type = SubFactory(AddressTypeFactory)
- organisation = SubFactory(OrganisationFactory)
- line1 = Faker("secondary_address", locale="en_GB")
- line2 = Faker("street_name", locale="en_GB")
- line3 = Faker("secondary_address", locale="en_GB")
- city = Faker("city", locale="en_GB")
- county = Faker("lexify", locale="en_GB", text="??????", letters="aeioutzyj")
- postcode = Faker("postcode", locale="en_GB")
- country = Faker("country")
- other_details = Faker("lexify", locale="en_GB", text="??????", letters="aeioutzyj")
-
- class Meta:
- model = Address
+from factory import DjangoModelFactory, Faker, post_generation
class UserFactory(DjangoModelFactory):