aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/conftest.py4
-rw-r--r--ctrack/organisations/management/commands/populate_db.py4
-rw-r--r--ctrack/organisations/tests/factories.py6
3 files changed, 5 insertions, 9 deletions
diff --git a/ctrack/conftest.py b/ctrack/conftest.py
index a3ed183..8c40fe4 100644
--- a/ctrack/conftest.py
+++ b/ctrack/conftest.py
@@ -1,6 +1,7 @@
import pytest
from django.test import RequestFactory
+from ctrack.organisations.models import AddressType
from ctrack.users.models import User
from ctrack.organisations.models import Organisation, Address
from ctrack.users.tests.factories import (
@@ -26,7 +27,8 @@ def org() -> Organisation:
@pytest.fixture
def addr() -> Address:
- return AddressFactory()
+ address_type = AddressType.objects.create(descriptor="Random Type")
+ return AddressFactory(type=address_type)
@pytest.fixture
diff --git a/ctrack/organisations/management/commands/populate_db.py b/ctrack/organisations/management/commands/populate_db.py
index 1613cde..4477b63 100644
--- a/ctrack/organisations/management/commands/populate_db.py
+++ b/ctrack/organisations/management/commands/populate_db.py
@@ -40,10 +40,6 @@ class Command(BaseCommand):
submodes = [sb1, sb2, sb3, sb4, sb5, sb6, sb7]
- # TODO: Create 40 odd organisations here, get their ids and pass them into PersonFactory.create_batch()
- # below. Then we need to write a post_generation hook in PersonFactory which ensures that the person
- # is only added to these Organisations and no further Organisation objects are created.
-
# we need a User object to completed the updated_by fields in Organisation and Person
user = (
UserFactory.create()
diff --git a/ctrack/organisations/tests/factories.py b/ctrack/organisations/tests/factories.py
index b082290..fd8ad88 100644
--- a/ctrack/organisations/tests/factories.py
+++ b/ctrack/organisations/tests/factories.py
@@ -46,7 +46,6 @@ class OrganisationFactory(DjangoModelFactory):
name = Faker("company")
slug = Faker("lexify", text="????", letters="abcdsg")
-# submode = SubFactory(SubModeFactory)
designation_type = 1
registered_company_name = Faker("company")
registered_company_number = Faker("numerify", text="######")
@@ -96,7 +95,7 @@ class PersonFactory(DjangoModelFactory):
landline = Faker("phone_number", locale="en_GB")
date_updated = factory.LazyFunction(datetime.now)
updated_by = SubFactory(UserFactory)
- clearance = factory.LazyFunction(lambda: random.randint(1,6))
+ clearance = factory.LazyFunction(lambda: random.randint(1, 6))
clearance_sponsor = Faker("name", locale="en_GB")
clearance_start_date = factory.LazyFunction(datetime.now)
clearance_last_checked = factory.LazyFunction(datetime.now)
@@ -108,7 +107,7 @@ class PersonFactory(DjangoModelFactory):
class AddressFactory(DjangoModelFactory):
- type = SubFactory("ctrack.organisations.tests.factories.AddressTypeFactory")
+ # type = # manually entered
organisation = SubFactory(OrganisationFactory)
line1 = Faker("building_number", locale="en_GB")
line2 = Faker("street_name", locale="en_GB")
@@ -121,4 +120,3 @@ class AddressFactory(DjangoModelFactory):
class Meta:
model = Address
-