Replies: 4 comments 4 replies
-
When I have it on the default settings, I get the following:
I added a print statement here: @pytest.fixture(scope="module")
def superuser_token_headers(client: TestClient) -> dict[str, str]:
print(get_superuser_token_headers(client))
return get_superuser_token_headers(client) and added
After changing password to
|
Beta Was this translation helpful? Give feedback.
-
Appears that this is the problem: def test_reset_password(
client: TestClient, superuser_token_headers: dict[str, str]
) -> None:
token = generate_password_reset_token(email=settings.FIRST_SUPERUSER)
data = {"new_password": "changethis", "token": token}
r = client.post(
f"{settings.API_V1_STR}/reset-password/",
headers=superuser_token_headers,
json=data,
)
assert r.status_code == 200
assert r.json() == {"message": "Password updated successfully"} If you change this to : def test_reset_password(
client: TestClient, superuser_token_headers: dict[str, str]
) -> None:
token = generate_password_reset_token(email=settings.FIRST_SUPERUSER)
data = {"new_password": settings.FIRST_SUPERUSER_PASSWORD, "token": token}
r = client.post(
f"{settings.API_V1_STR}/reset-password/",
headers=superuser_token_headers,
json=data,
)
assert r.status_code == 200
assert r.json() == {"message": "Password updated successfully"} all tests succeed. |
Beta Was this translation helpful? Give feedback.
-
Added PR here: #1213 |
Beta Was this translation helpful? Give feedback.
-
I also ran into this. I'm not sure why this test is written to break if you actually change the FIRST_SUPERUSER_PASSWORD. If instead of using "changethis" you use the FIRST_SUPERUSER_PASSWORD, whatever its set to, then its not a great test because you don't actually test if the password got changed since you're changing it to the same password. In my opinion there are two approaches, 1) you can create a throw away user (like test_create_user_by_normal_user) to actually change the password for, then it won't mess with the superuser's password, or 2) once you change it to "changethis", change it back to the original password, thus restoring the state (this is what test_update_password_me does). Is the idea to only run the tests with totally clean data and have it return to that state after the tests? |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
Used copier to template the repo. When I do this, the users tests fail.
The
.env
has this for default:mine was changed to this:
And I get the following errors:
When I revert back to the default values above, they all pass.
Operating System
macOS
Operating System Details
I am using docker compose for this.
Python Version
3.12
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions