-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌱(dashboard) add consent development fixtures
Create and manage consent development fixtures. The seed-dashboard Makefile target was updated to include the fixture creation command.
- Loading branch information
Showing
6 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Dashboard consent app fixtures.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Dashboard consent dev fixture.""" | ||
|
||
from apps.auth.factories import UserFactory | ||
from apps.consent.factories import ConsentFactory | ||
from apps.core.factories import DeliveryPointFactory, EntityFactory | ||
from apps.core.models import DeliveryPoint | ||
|
||
|
||
def seed_consent(): | ||
"""Creates development fixtures for consent management system. | ||
This function performs the following tasks: | ||
1. Creates three user instances using UserFactory. | ||
2. Creates three entity instances with assigned users using EntityFactory. | ||
3. Creates multiple delivery points for each entity using DeliveryPointFactory. | ||
4. Generates consent instances for each delivery point using ConsentFactory. | ||
""" | ||
# create users | ||
user1 = UserFactory(username="user1") | ||
user2 = UserFactory(username="user2") | ||
user3 = UserFactory(username="user3") | ||
user4 = UserFactory(username="user4") | ||
user5 = UserFactory(username="user5") | ||
|
||
# create entities | ||
entity1 = EntityFactory(users=(user1,)) | ||
entity2 = EntityFactory(users=(user2, user4)) | ||
entity3 = EntityFactory(users=(user3,), proxy_for=(entity1, entity2)) | ||
entity4 = EntityFactory(users=(user5,)) | ||
|
||
|
||
# create delivery points | ||
for i in range(1, 4): | ||
DeliveryPointFactory(provider_assigned_id=f"entity1_{i}", entity=entity1) | ||
DeliveryPointFactory(provider_assigned_id=f"entity2_{i}", entity=entity2) | ||
DeliveryPointFactory(provider_assigned_id=f"entity3_{i}", entity=entity3) | ||
DeliveryPointFactory(provider_assigned_id=f"entity4_{i}", entity=entity4) | ||
|
||
# create awaiting consents | ||
for delivery_point in DeliveryPoint.objects.all(): | ||
ConsentFactory(delivery_point=delivery_point, created_by=user1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Dashboard consent app management.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Dashboard consent app management commands.""" |
19 changes: 19 additions & 0 deletions
19
src/dashboard/apps/consent/management/commands/seed_consent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Consent management commands.""" | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from apps.consent.fixtures.consent import seed_consent | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Create development fixtures for the consent management system.""" | ||
|
||
help = __doc__ | ||
|
||
def handle(self, *args, **kwargs): | ||
"""Executes the command for creating development consent fixtures.""" | ||
self.stdout.write(self.style.NOTICE("Seeding database with consents...")) | ||
seed_consent() | ||
self.stdout.write( | ||
self.style.SUCCESS("Done.") | ||
) |