From 0bfe3454fde753425d37246b73b3eda1b9a756b9 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 21 Jan 2020 10:12:56 +0000 Subject: fixed failing test - first use of faker object --- .../migrations/0003_organisation_address.py | 19 +++++++++++++++++++ ctrack/organisations/models.py | 1 + ctrack/users/tests/factories.py | 16 ++++++++-------- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 ctrack/organisations/migrations/0003_organisation_address.py (limited to 'ctrack') diff --git a/ctrack/organisations/migrations/0003_organisation_address.py b/ctrack/organisations/migrations/0003_organisation_address.py new file mode 100644 index 0000000..6437d29 --- /dev/null +++ b/ctrack/organisations/migrations/0003_organisation_address.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.9 on 2020-01-21 10:06 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0002_address'), + ] + + operations = [ + migrations.AddField( + model_name='organisation', + name='address', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='organisations.Address'), + ), + ] diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py index 01127cc..3ef794c 100644 --- a/ctrack/organisations/models.py +++ b/ctrack/organisations/models.py @@ -18,6 +18,7 @@ class Address(models.Model): class Organisation(models.Model): name = models.CharField(max_length=255, blank=False) + address = models.ForeignKey(Address, on_delete=models.CASCADE, blank=True, null=True) def get_absolute_url(self): return reverse("organisations:detail", kwargs={"name": self.slugify_name()}) diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py index b104a23..6c5c7cd 100644 --- a/ctrack/users/tests/factories.py +++ b/ctrack/users/tests/factories.py @@ -7,21 +7,21 @@ from factory import DjangoModelFactory, Faker, post_generation class OrganisationFactory(DjangoModelFactory): - name = Faker("name") + name = Faker("company", locale="en_GB") class Meta: model = Organisation class AddressFactory(DjangoModelFactory): - line1 = Faker("line1") - line2 = Faker("line2") - line3 = Faker("line3") - city = Faker("city") - county = Faker("county") - postcode = Faker("postcode") + 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("other_details") + other_details = Faker("lexify", locale="en_GB", text="??????", letters="aeioutzyj") class Meta: model = Address -- cgit v1.2.3