aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/conftest.py7
-rw-r--r--ctrack/organisations/migrations/0002_address.py27
-rw-r--r--ctrack/organisations/models.py11
-rw-r--r--ctrack/organisations/tests/test_models.py10
-rw-r--r--ctrack/users/tests/factories.py16
5 files changed, 67 insertions, 4 deletions
diff --git a/ctrack/conftest.py b/ctrack/conftest.py
index 36254cd..2efd243 100644
--- a/ctrack/conftest.py
+++ b/ctrack/conftest.py
@@ -2,8 +2,8 @@ import pytest
from django.test import RequestFactory
from ctrack.users.models import User
-from ctrack.organisations.models import Organisation
-from ctrack.users.tests.factories import UserFactory, OrganisationFactory
+from ctrack.organisations.models import Organisation, Address
+from ctrack.users.tests.factories import UserFactory, OrganisationFactory, AddressFactory
@pytest.fixture(autouse=True)
@@ -20,6 +20,9 @@ def user() -> User:
def org() -> Organisation:
return OrganisationFactory()
+@pytest.fixture
+def addr() -> Address:
+ return AddressFactory()
@pytest.fixture
def request_factory() -> RequestFactory:
diff --git a/ctrack/organisations/migrations/0002_address.py b/ctrack/organisations/migrations/0002_address.py
new file mode 100644
index 0000000..59227d4
--- /dev/null
+++ b/ctrack/organisations/migrations/0002_address.py
@@ -0,0 +1,27 @@
+# Generated by Django 2.2.9 on 2020-01-20 20:39
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('organisations', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Address',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('line1', models.CharField(max_length=255)),
+ ('line2', models.CharField(max_length=255)),
+ ('line3', models.CharField(max_length=255)),
+ ('city', models.CharField(max_length=100)),
+ ('county', models.CharField(max_length=100)),
+ ('postcode', models.CharField(max_length=10)),
+ ('country', models.CharField(max_length=100)),
+ ('other_details', models.CharField(max_length=255)),
+ ],
+ ),
+ ]
diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py
index 976e661..01127cc 100644
--- a/ctrack/organisations/models.py
+++ b/ctrack/organisations/models.py
@@ -5,6 +5,17 @@ from django.urls import reverse
from slugify import slugify
+class Address(models.Model):
+ line1 = models.CharField(max_length=255)
+ line2 = models.CharField(max_length=255)
+ line3 = models.CharField(max_length=255)
+ city = models.CharField(max_length=100)
+ county = models.CharField(max_length=100)
+ postcode = models.CharField(max_length=10)
+ country = models.CharField(max_length=100)
+ other_details = models.CharField(max_length=255)
+
+
class Organisation(models.Model):
name = models.CharField(max_length=255, blank=False)
diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py
index 1307a83..f642c11 100644
--- a/ctrack/organisations/tests/test_models.py
+++ b/ctrack/organisations/tests/test_models.py
@@ -1,7 +1,7 @@
import pytest
from slugify import slugify
-from ..models import Organisation
+from ..models import Organisation, Address
pytestmark = pytest.mark.django_db
@@ -9,3 +9,11 @@ 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")
diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py
index d4b9544..b104a23 100644
--- a/ctrack/users/tests/factories.py
+++ b/ctrack/users/tests/factories.py
@@ -1,7 +1,7 @@
from typing import Any, Sequence
from django.contrib.auth import get_user_model
-from ctrack.organisations.models import Organisation
+from ctrack.organisations.models import Organisation, Address
from factory import DjangoModelFactory, Faker, post_generation
@@ -13,6 +13,20 @@ class OrganisationFactory(DjangoModelFactory):
model = Organisation
+class AddressFactory(DjangoModelFactory):
+ line1 = Faker("line1")
+ line2 = Faker("line2")
+ line3 = Faker("line3")
+ city = Faker("city")
+ county = Faker("county")
+ postcode = Faker("postcode")
+ country = Faker("country")
+ other_details = Faker("other_details")
+
+ class Meta:
+ model = Address
+
+
class UserFactory(DjangoModelFactory):
username = Faker("user_name")