diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-01-20 20:54:42 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-01-20 20:54:42 +0000 |
commit | 793d16fbc7d531c575601a64be91f7ac8250aab0 (patch) | |
tree | 06af18fa90f13702daad49cecc4f902241c06d93 /ctrack/organisations | |
parent | b3ba5d7a9758a0e167409757dbe46dfc75bade5c (diff) |
partial way through playing with Faker
Diffstat (limited to 'ctrack/organisations')
-rw-r--r-- | ctrack/organisations/migrations/0002_address.py | 27 | ||||
-rw-r--r-- | ctrack/organisations/models.py | 11 | ||||
-rw-r--r-- | ctrack/organisations/tests/test_models.py | 10 |
3 files changed, 47 insertions, 1 deletions
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") |