Merge pull request #3607 from cisagov/es/fixtures-quickfix

Fixtures quickfix [local testing]
This commit is contained in:
Erin Song 2025-03-06 09:36:25 -08:00 committed by GitHub
commit e3fdb4de56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -315,25 +315,11 @@ class DomainRequestFixture:
cls._create_domain_requests(users)
@classmethod
def _create_domain_requests(cls, users, total_requests=None): # noqa: C901
def _create_domain_requests(cls, users): # noqa: C901
"""Creates DomainRequests given a list of users."""
total_domain_requests_to_make = len(users) # 100000
# Check if the database is already populated with the desired
# number of entries.
# (Prevents re-adding more entries to an already populated database,
# which happens when restarting Docker src)
total_existing_requests = DomainRequest.objects.count()
domain_requests_to_create = []
if total_requests and total_requests <= total_existing_requests:
total_domain_requests_to_make = total_requests - total_existing_requests
if total_domain_requests_to_make >= 0:
DomainRequest.objects.filter(
id__in=list(DomainRequest.objects.values_list("pk", flat=True)[:total_domain_requests_to_make])
).delete()
if total_domain_requests_to_make == 0:
return
for user in users:
for request_data in cls.DOMAINREQUESTS: