This commit is contained in:
Rachid Mrad 2024-11-20 13:15:27 -05:00
parent 2b3ce1cdfb
commit ec8e8b1f65
No known key found for this signature in database
2 changed files with 6 additions and 7 deletions

View file

@ -194,8 +194,8 @@ class DomainRequestFixture:
if not request.requested_domain:
if "requested_domain" in request_dict and request_dict["requested_domain"] is not None:
return DraftDomain.objects.get_or_create(name=request_dict["requested_domain"])[0]
# Generate a unique fake domain
# Generate a unique fake domain
return cls.fake_dot_gov()
return request.requested_domain
@ -233,19 +233,19 @@ class DomainRequestFixture:
except Exception as e:
logger.warning(f"Expected fixture portfolio, did not find it: {e}")
return None
@classmethod
def _get_random_sub_organization(cls, request):
try:
# Filter Suborganizations by the request's portfolio
portfolio_suborganizations = Suborganization.objects.filter(portfolio=request.portfolio)
# Assuming SuborganizationFixture.SUBORGS is a list of dictionaries with a "name" key
suborganization_names = [suborg["name"] for suborg in SuborganizationFixture.SUBORGS]
# Further filter by names in suborganization_names
suborganization_options = portfolio_suborganizations.filter(name__in=suborganization_names)
# Randomly choose one if any exist
return random.choice(suborganization_options) if suborganization_options.exists() else None # nosec
except Exception as e:

View file

@ -161,7 +161,6 @@ class UserFixture:
]
STAFF = [
# {
# "username": "994b7a90-f1d1-4140-a3d2-ff34183c7ee2",
# "first_name": "Rach test staff",
@ -344,7 +343,7 @@ class UserFixture:
# Only append the user if any of the fields were updated
if updated:
users_to_update.append(user)
# Save any users that were updated
if users_to_update:
User.objects.bulk_update(users_to_update, ["is_staff"])