diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-02-20 13:33:48 +0000 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-02-20 13:33:48 +0000 |
commit | 9c1e4edd81d676c92503061c24f7e8660cc94482 (patch) | |
tree | 485e3af65a192196ac73402e6b6b5279e758f8a0 /ctrack/organisations/tests | |
parent | 7523b27d1e67fa32584f1d34777faf2e53ce6edf (diff) |
failing test - need to tweak db
Diffstat (limited to 'ctrack/organisations/tests')
-rw-r--r-- | ctrack/organisations/tests/factories.py | 25 | ||||
-rw-r--r-- | ctrack/organisations/tests/test_models.py | 10 |
2 files changed, 29 insertions, 6 deletions
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 |