Skip to content

Commit

Permalink
chore: add tests for clients CRUD REST APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Nov 9, 2021
1 parent e44d0f9 commit 5dad3ee
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 42 deletions.
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"wagtail.core",
"taggit",
"modelcluster",
"django_extensions",
]

LOCAL_APPS = [
Expand Down
5 changes: 0 additions & 5 deletions config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,3 @@
except socket.gaierror:
# The node container isn't started (yet?)
pass

# django-extensions
# ------------------------------------------------------------------------------
# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
INSTALLED_APPS += ["django_extensions"] # noqa F405
24 changes: 24 additions & 0 deletions mycarehub/clients/migrations/0003_auto_20211109_1338.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.9 on 2021-11-09 10:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('common', '0004_alter_auditlog_timestamp'),
('clients', '0002_auto_20211109_0922'),
]

operations = [
migrations.AlterField(
model_name='relatedperson',
name='addresses',
field=models.ManyToManyField(blank=True, null=True, related_name='related_person_addresses', to='common.Address'),
),
migrations.AlterField(
model_name='relatedperson',
name='contacts',
field=models.ManyToManyField(blank=True, null=True, related_name='related_person_contacts', to='common.Contact'),
),
]
34 changes: 34 additions & 0 deletions mycarehub/clients/migrations/0004_auto_20211109_1345.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.9 on 2021-11-09 10:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('common', '0004_alter_auditlog_timestamp'),
('clients', '0003_auto_20211109_1338'),
]

operations = [
migrations.AlterField(
model_name='client',
name='addresses',
field=models.ManyToManyField(blank=True, null=True, related_name='client_addresses', to='common.Address'),
),
migrations.AlterField(
model_name='client',
name='contacts',
field=models.ManyToManyField(blank=True, null=True, related_name='client_contacts', to='common.Contact'),
),
migrations.AlterField(
model_name='client',
name='related_persons',
field=models.ManyToManyField(blank=True, null=True, related_name='client_related_persons', to='clients.RelatedPerson'),
),
migrations.AlterField(
model_name='client',
name='treatment_buddy',
field=models.TextField(blank=True, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-09 11:07

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('common', '0004_alter_auditlog_timestamp'),
('clients', '0004_auto_20211109_1345'),
]

operations = [
migrations.AlterUniqueTogether(
name='clientfacility',
unique_together={('client', 'facility')},
),
]
18 changes: 18 additions & 0 deletions mycarehub/clients/migrations/0006_clientfacility_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-09 11:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('clients', '0005_alter_clientfacility_unique_together'),
]

operations = [
migrations.AddField(
model_name='clientfacility',
name='notes',
field=models.TextField(default='-'),
),
]
32 changes: 23 additions & 9 deletions mycarehub/clients/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ class RelationshipType(TextChoices):
last_name = models.TextField()
other_name = models.TextField()
date_of_birth = models.DateField(null=True, blank=True)
addresses = models.ManyToManyField(Address, related_name="related_person_addresses")
contacts = models.ManyToManyField(Contact, related_name="related_person_contacts")
gender = models.CharField(max_length=16, choices=GenderChoices.choices)
relationship_type = models.CharField(max_length=64, choices=RelationshipType.choices)
addresses = models.ManyToManyField(
Address, related_name="related_person_addresses", null=True, blank=True
)
contacts = models.ManyToManyField(
Contact, related_name="related_person_contacts", null=True, blank=True
)


class Client(AbstractBase):
Expand Down Expand Up @@ -186,7 +190,7 @@ class Languages(TextChoices):
)

# a client can be assigned a treatment buddy
treatment_buddy = models.TextField(blank=True)
treatment_buddy = models.TextField(null=True, blank=True)

# a client should only be invited to the platform after they have been
# counselled
Expand All @@ -195,12 +199,15 @@ class Languages(TextChoices):
# a client can have multiple unique identifiers
identifiers = models.ManyToManyField(Identifier, related_name="client_identifiers")

addresses = models.ManyToManyField(Address, related_name="client_addresses")

contacts = models.ManyToManyField(Contact, related_name="client_contacts")

related_persons = models.ManyToManyField(RelatedPerson, related_name="client_related_persons")

addresses = models.ManyToManyField(
Address, related_name="client_addresses", null=True, blank=True
)
contacts = models.ManyToManyField(
Contact, related_name="client_contacts", null=True, blank=True
)
related_persons = models.ManyToManyField(
RelatedPerson, related_name="client_related_persons", null=True, blank=True
)
languages = ArrayField(
models.CharField(max_length=150, choices=Languages.choices, null=True, blank=True),
null=True,
Expand All @@ -215,5 +222,12 @@ class ClientFacility(AbstractBase):

client = models.ForeignKey(Client, on_delete=models.PROTECT)
facility = models.ForeignKey(Facility, on_delete=models.PROTECT)
notes = models.TextField(default="-")
assigned = models.DateTimeField(default=timezone.now)
transferred_out = models.DateTimeField(null=True, blank=True)

class Meta(AbstractBase.Meta):
unique_together = (
"client",
"facility",
)
Loading

0 comments on commit 5dad3ee

Please sign in to comment.