aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations/tests
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-23 21:16:46 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-23 21:16:46 +0100
commit3eb799b67c9d6cc7905c9e5ce7210a53ed7f2b66 (patch)
tree30ff9c29a08fa3de8d4a4141058ac43960b0a693 /ctrack/organisations/tests
parent340ae8d6fdbacb370777560b68674406eb554a18 (diff)
fixed a test and some cleaning
Diffstat (limited to 'ctrack/organisations/tests')
-rw-r--r--ctrack/organisations/tests/factories.py14
-rw-r--r--ctrack/organisations/tests/test_views.py9
2 files changed, 17 insertions, 6 deletions
diff --git a/ctrack/organisations/tests/factories.py b/ctrack/organisations/tests/factories.py
index 3550f6e..7acd887 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 Organisation, Person, Role, Address
+from ctrack.organisations.models import Address, Organisation, Person, Role
User = get_user_model()
@@ -47,7 +47,7 @@ class OrganisationFactory(DjangoModelFactory):
name = Faker("company")
slug = Faker("lexify", text="????", letters="abcdsg")
designation_type = 1
- oes = factory.LazyFunction(lambda : random.choice([True, False]))
+ oes = factory.LazyFunction(lambda: random.choice([True, False]))
registered_company_name = Faker("company")
registered_company_number = Faker("numerify", text="######")
date_updated = Faker("date_this_year", before_today=True)
@@ -82,15 +82,19 @@ class PersonFactory(DjangoModelFactory):
if extracted:
self.role.add(extracted)
- primary_nis_contact = factory.LazyFunction(lambda : random.choice([True, False]))
+ primary_nis_contact = factory.LazyFunction(lambda: random.choice([True, False]))
voluntary_point_of_contact = True
has_egress = False
title = factory.LazyFunction(lambda: random.randint(1, 8))
job_title = Faker("job")
first_name = Faker("first_name")
last_name = Faker("last_name")
- organisation = SubFactory("ctrack.organisations.tests.factories.OrganisationFactory")
- email = factory.LazyAttribute(lambda o: '%s@%s.com' % (o.first_name.lower(), o.organisation.slug))
+ organisation = SubFactory(
+ "ctrack.organisations.tests.factories.OrganisationFactory"
+ )
+ email = factory.LazyAttribute(
+ lambda o: "%s@%s.com" % (o.first_name.lower(), o.organisation.slug)
+ )
secondary_email = Faker("ascii_company_email")
mobile = Faker("cellphone_number", locale="en_GB")
landline = Faker("phone_number", locale="en_GB")
diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py
index 02d066a..2111410 100644
--- a/ctrack/organisations/tests/test_views.py
+++ b/ctrack/organisations/tests/test_views.py
@@ -2,13 +2,20 @@ import pytest
from django.contrib.auth import get_user_model
from django.test import RequestFactory
+from ctrack.organisations.tests.factories import OrganisationFactory
+
from ..views import OrganisationListView
pytestmark = pytest.mark.django_db
# https://docs.djangoproject.com/en/3.0/topics/testing/advanced/#example
-def test_organisation_list_view(full_db_fixture):
+def test_organisation_list_view():
+
+ OrganisationFactory.create()
+ OrganisationFactory.create()
+ OrganisationFactory.create()
+
factory = RequestFactory()
user = get_user_model().objects.create_user(
username="testy", email="testy@test.com", password="test1020"