-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are some broken tests from some legacy work. This fixes just some of them: the ones in test_api_views.py There were 4 issues causing the tests to fail that this change fixes: - An incorrect assumption on the form of an error message in the case of a 403 - Using a now-removed date_joined field - Passing an email address into model creation, where is also determined the email address based on username. - Assuming that a regular user can access the view-message endpoint, when they (correctly) cannot.
- Loading branch information
Showing
3 changed files
with
8 additions
and
16 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 |
---|---|---|
|
@@ -73,18 +73,15 @@ def default_ai_settings(db): # noqa: ARG001 | |
def create_user(): | ||
def _create_user( | ||
email, | ||
date_joined_iso, | ||
username, | ||
is_staff=False, | ||
grade=User.UserGrade.DIRECTOR, | ||
business_unit=User.BusinessUnit.DIGITAL_DATA_AND_TECHNOLOGY, | ||
profession=User.Profession.IA, | ||
ai_experience=User.AIExperienceLevel.EXPERIENCED_NAVIGATOR, | ||
): | ||
date_joined = datetime.fromisoformat(date_joined_iso).astimezone(UTC) | ||
return User.objects.create_user( | ||
email=email, | ||
date_joined=date_joined, | ||
is_staff=is_staff, | ||
grade=grade, | ||
business_unit=business_unit, | ||
|
@@ -98,9 +95,7 @@ def _create_user( | |
|
||
@pytest.fixture() | ||
def alice(create_user): | ||
return create_user( | ||
email="[email protected]", date_joined_iso="2000-01-01", username="[email protected]" | ||
) | ||
return create_user(email="[email protected]", username="[email protected]") | ||
|
||
|
||
@pytest.fixture() | ||
|
@@ -110,7 +105,7 @@ def chat_with_alice(alice): | |
|
||
@pytest.fixture() | ||
def bob(create_user): | ||
return create_user(email="[email protected]", date_joined_iso="2000-01-01", username="[email protected]") | ||
return create_user(email="[email protected]", username="[email protected]") | ||
|
||
|
||
@pytest.fixture() | ||
|
@@ -135,16 +130,12 @@ def user_with_demographic_data() -> User: | |
|
||
@pytest.fixture() | ||
def staff_user(create_user): | ||
return create_user( | ||
email="[email protected]", date_joined_iso="2000-01-01", is_staff=True, username="[email protected]" | ||
) | ||
return create_user(email="[email protected]", is_staff=True, username="[email protected]") | ||
|
||
|
||
@pytest.fixture() | ||
def superuser() -> User: | ||
return User.objects.create_superuser( | ||
email="[email protected]", date_joined_iso="2000-01-01", username="[email protected]" | ||
) | ||
return User.objects.create_superuser(email="[email protected]", username="[email protected]") | ||
|
||
|
||
@pytest.fixture() | ||
|
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