-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
17 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
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
admin_user: models_core.CoreUser | ||
ens_user: models_core.CoreUser | ||
fake_ens_user: models_core.CoreUser | ||
new_school_user: models_core.CoreUser | ||
|
||
UNIQUE_TOKEN = "my_unique_token" | ||
|
@@ -24,12 +25,12 @@ | |
|
||
@pytest_asyncio.fixture(scope="module", autouse=True) | ||
async def init_objects() -> None: | ||
global admin_user, ens_user, new_school_user | ||
global admin_user, ens_user, fake_ens_user, new_school_user | ||
|
||
ens = models_core.CoreSchool( | ||
id=id_test_ens, | ||
name="ENS", | ||
email_regex=r"^.*@ens.fr$", | ||
email_regex=r"^.*@.*ens.fr$", | ||
) | ||
await add_object_to_db(ens) | ||
|
||
|
@@ -41,6 +42,12 @@ async def init_objects() -> None: | |
email="[email protected]", | ||
account_type=AccountType.other_school_student, | ||
) | ||
fake_ens_user = await create_user_with_groups( | ||
[], | ||
school_id=id_test_ens, | ||
email="[email protected]", | ||
account_type=AccountType.other_school_student, | ||
) | ||
|
||
new_school_user = await create_user_with_groups( | ||
[], | ||
|
@@ -123,7 +130,7 @@ def test_update_school(client: TestClient) -> None: | |
|
||
response = client.patch( | ||
f"/schools/{id_test_ens}", | ||
json={"name": "school ENS", "email_regex": r"^.*@.*ens.fr$"}, | ||
json={"name": "school ENS", "email_regex": r"^.*@ens.fr$"}, | ||
headers={"Authorization": f"Bearer {token}"}, | ||
) | ||
assert response.status_code == 204 | ||
|
@@ -135,6 +142,20 @@ def test_update_school(client: TestClient) -> None: | |
data = response.json() | ||
assert data["name"] == "school ENS" | ||
|
||
response = client.get( | ||
f"/users/{ens_user.id}", | ||
headers={"Authorization": f"Bearer {token}"}, | ||
) | ||
data = response.json() | ||
assert data["school_id"] == str(id_test_ens) | ||
|
||
response = client.get( | ||
f"/users/{fake_ens_user.id}", | ||
headers={"Authorization": f"Bearer {token}"}, | ||
) | ||
data = response.json() | ||
assert data["school_id"] == str(SchoolType.no_school.value) | ||
|
||
|
||
def test_create_user_corresponding_to_school( | ||
mocker: MockerFixture, | ||
|