Skip to content

Commit 1d24352

Browse files
authored
Merge pull request #80 from rafsaf/dependabot/pip/all-dependencies-27b3656dda
Bump the all-dependencies group across 1 directory with 25 updates
2 parents fb0284c + 7dba35d commit 1d24352

11 files changed

+787
-956
lines changed

app/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Settings(BaseSettings):
4646
security: Security
4747
database: Database
4848

49-
@computed_field # type: ignore[misc]
49+
@computed_field # type: ignore[prop-decorator]
5050
@property
5151
def sqlalchemy_database_uri(self) -> URL:
5252
return URL.create(

app/tests/conftest.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import asyncio
1+
import logging
22
import os
3-
from collections.abc import AsyncGenerator, Generator
3+
from collections.abc import AsyncGenerator
44

55
import pytest
66
import pytest_asyncio
@@ -24,12 +24,17 @@
2424
default_user_access_token = create_jwt_token(default_user_id).access_token
2525

2626

27-
@pytest.fixture(scope="session")
28-
def event_loop() -> Generator[asyncio.AbstractEventLoop, None, None]:
29-
loop = asyncio.new_event_loop()
30-
asyncio.set_event_loop(loop)
31-
yield loop
32-
loop.close()
27+
# @pytest.fixture(scope="session")
28+
# def event_loop_policy():
29+
# return uvloop.EventLoopPolicy()
30+
31+
32+
# @pytest.fixture(scope="session")
33+
# def event_loop() -> Generator[asyncio.AbstractEventLoop, None, None]:
34+
# loop = asyncio.new_event_loop()
35+
# asyncio.set_event_loop(loop)
36+
# yield loop
37+
# loop.close()
3338

3439

3540
@pytest_asyncio.fixture(scope="session", autouse=True)
@@ -102,6 +107,7 @@ async def fixture_session_with_rollback(
102107

103108
yield session
104109

110+
logging.critical("Rolling back transaction")
105111
await session.close()
106112
await transaction.rollback()
107113
await connection.close()
@@ -118,18 +124,20 @@ async def fixture_client(session: AsyncSession) -> AsyncGenerator[AsyncClient, N
118124
@pytest_asyncio.fixture(name="default_user", scope="function")
119125
async def fixture_default_user(
120126
session: AsyncSession, default_hashed_password: str
121-
) -> User:
127+
) -> AsyncGenerator[User, None]:
122128
default_user = User(
123129
user_id=default_user_id,
124130
email=default_user_email,
125131
hashed_password=default_hashed_password,
126132
)
127133
session.add(default_user)
134+
128135
await session.commit()
129136
await session.refresh(default_user)
130-
return default_user
137+
138+
yield default_user
131139

132140

133-
@pytest.fixture(name="default_user_headers", scope="function")
141+
@pytest_asyncio.fixture(name="default_user_headers", scope="function")
134142
def fixture_default_user_headers(default_user: User) -> dict[str, str]:
135143
return {"Authorization": f"Bearer {default_user_access_token}"}

app/tests/test_api_router_jwt_errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from app.models import User
1212

1313

14+
@pytest.mark.asyncio(loop_scope="session")
1415
@pytest.mark.parametrize("api_route", api_router.routes)
1516
async def test_api_routes_raise_401_on_jwt_decode_errors(
1617
client: AsyncClient,
@@ -26,6 +27,7 @@ async def test_api_routes_raise_401_on_jwt_decode_errors(
2627
assert response.json() == {"detail": "Token invalid: Not enough segments"}
2728

2829

30+
@pytest.mark.asyncio(loop_scope="session")
2931
@pytest.mark.parametrize("api_route", api_router.routes)
3032
async def test_api_routes_raise_401_on_jwt_expired_token(
3133
client: AsyncClient,
@@ -45,6 +47,7 @@ async def test_api_routes_raise_401_on_jwt_expired_token(
4547
assert response.json() == {"detail": "Token invalid: Signature has expired"}
4648

4749

50+
@pytest.mark.asyncio(loop_scope="session")
4851
@pytest.mark.parametrize("api_route", api_router.routes)
4952
async def test_api_routes_raise_401_on_jwt_user_deleted(
5053
client: AsyncClient,

app/tests/test_auth/test_access_token.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22

3+
import pytest
34
from fastapi import status
45
from freezegun import freeze_time
56
from httpx import AsyncClient
@@ -14,6 +15,7 @@
1415
from app.tests.conftest import default_user_password
1516

1617

18+
@pytest.mark.asyncio(loop_scope="session")
1719
async def test_login_access_token_has_response_status_code(
1820
client: AsyncClient,
1921
default_user: User,
@@ -30,6 +32,7 @@ async def test_login_access_token_has_response_status_code(
3032
assert response.status_code == status.HTTP_200_OK
3133

3234

35+
@pytest.mark.asyncio(loop_scope="session")
3336
async def test_login_access_token_jwt_has_valid_token_type(
3437
client: AsyncClient,
3538
default_user: User,
@@ -47,6 +50,7 @@ async def test_login_access_token_jwt_has_valid_token_type(
4750
assert token["token_type"] == "Bearer"
4851

4952

53+
@pytest.mark.asyncio(loop_scope="session")
5054
@freeze_time("2023-01-01")
5155
async def test_login_access_token_jwt_has_valid_expire_time(
5256
client: AsyncClient,
@@ -69,6 +73,7 @@ async def test_login_access_token_jwt_has_valid_expire_time(
6973
)
7074

7175

76+
@pytest.mark.asyncio(loop_scope="session")
7277
@freeze_time("2023-01-01")
7378
async def test_login_access_token_returns_valid_jwt_access_token(
7479
client: AsyncClient,
@@ -92,6 +97,7 @@ async def test_login_access_token_returns_valid_jwt_access_token(
9297
assert token_payload.exp == token["expires_at"]
9398

9499

100+
@pytest.mark.asyncio(loop_scope="session")
95101
async def test_login_access_token_refresh_token_has_valid_expire_time(
96102
client: AsyncClient,
97103
default_user: User,
@@ -113,6 +119,7 @@ async def test_login_access_token_refresh_token_has_valid_expire_time(
113119
)
114120

115121

122+
@pytest.mark.asyncio(loop_scope="session")
116123
async def test_login_access_token_refresh_token_exists_in_db(
117124
client: AsyncClient,
118125
default_user: User,
@@ -135,6 +142,7 @@ async def test_login_access_token_refresh_token_exists_in_db(
135142
assert token_db_count == 1
136143

137144

145+
@pytest.mark.asyncio(loop_scope="session")
138146
async def test_login_access_token_refresh_token_in_db_has_valid_fields(
139147
client: AsyncClient,
140148
default_user: User,
@@ -160,6 +168,7 @@ async def test_login_access_token_refresh_token_in_db_has_valid_fields(
160168
assert not refresh_token.used
161169

162170

171+
@pytest.mark.asyncio(loop_scope="session")
163172
async def test_auth_access_token_fail_for_not_existing_user_with_message(
164173
client: AsyncClient,
165174
) -> None:
@@ -176,6 +185,7 @@ async def test_auth_access_token_fail_for_not_existing_user_with_message(
176185
assert response.json() == {"detail": api_messages.PASSWORD_INVALID}
177186

178187

188+
@pytest.mark.asyncio(loop_scope="session")
179189
async def test_auth_access_token_fail_for_invalid_password_with_message(
180190
client: AsyncClient,
181191
default_user: User,

app/tests/test_auth/test_auth_refresh_token.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22

3+
import pytest
34
from fastapi import status
45
from freezegun import freeze_time
56
from httpx import AsyncClient
@@ -13,6 +14,7 @@
1314
from app.models import RefreshToken, User
1415

1516

17+
@pytest.mark.asyncio(loop_scope="session")
1618
async def test_refresh_token_fails_with_message_when_token_does_not_exist(
1719
client: AsyncClient,
1820
) -> None:
@@ -27,6 +29,7 @@ async def test_refresh_token_fails_with_message_when_token_does_not_exist(
2729
assert response.json() == {"detail": api_messages.REFRESH_TOKEN_NOT_FOUND}
2830

2931

32+
@pytest.mark.asyncio(loop_scope="session")
3033
async def test_refresh_token_fails_with_message_when_token_is_expired(
3134
client: AsyncClient,
3235
default_user: User,
@@ -51,6 +54,7 @@ async def test_refresh_token_fails_with_message_when_token_is_expired(
5154
assert response.json() == {"detail": api_messages.REFRESH_TOKEN_EXPIRED}
5255

5356

57+
@pytest.mark.asyncio(loop_scope="session")
5458
async def test_refresh_token_fails_with_message_when_token_is_used(
5559
client: AsyncClient,
5660
default_user: User,
@@ -76,6 +80,7 @@ async def test_refresh_token_fails_with_message_when_token_is_used(
7680
assert response.json() == {"detail": api_messages.REFRESH_TOKEN_ALREADY_USED}
7781

7882

83+
@pytest.mark.asyncio(loop_scope="session")
7984
async def test_refresh_token_success_response_status_code(
8085
client: AsyncClient,
8186
default_user: User,
@@ -100,6 +105,7 @@ async def test_refresh_token_success_response_status_code(
100105
assert response.status_code == status.HTTP_200_OK
101106

102107

108+
@pytest.mark.asyncio(loop_scope="session")
103109
async def test_refresh_token_success_old_token_is_used(
104110
client: AsyncClient,
105111
default_user: User,
@@ -128,6 +134,7 @@ async def test_refresh_token_success_old_token_is_used(
128134
assert used_test_refresh_token.used
129135

130136

137+
@pytest.mark.asyncio(loop_scope="session")
131138
async def test_refresh_token_success_jwt_has_valid_token_type(
132139
client: AsyncClient,
133140
default_user: User,
@@ -153,6 +160,7 @@ async def test_refresh_token_success_jwt_has_valid_token_type(
153160
assert token["token_type"] == "Bearer"
154161

155162

163+
@pytest.mark.asyncio(loop_scope="session")
156164
@freeze_time("2023-01-01")
157165
async def test_refresh_token_success_jwt_has_valid_expire_time(
158166
client: AsyncClient,
@@ -183,6 +191,7 @@ async def test_refresh_token_success_jwt_has_valid_expire_time(
183191
)
184192

185193

194+
@pytest.mark.asyncio(loop_scope="session")
186195
@freeze_time("2023-01-01")
187196
async def test_refresh_token_success_jwt_has_valid_access_token(
188197
client: AsyncClient,
@@ -214,6 +223,7 @@ async def test_refresh_token_success_jwt_has_valid_access_token(
214223
assert token_payload.exp == token["expires_at"]
215224

216225

226+
@pytest.mark.asyncio(loop_scope="session")
217227
@freeze_time("2023-01-01")
218228
async def test_refresh_token_success_refresh_token_has_valid_expire_time(
219229
client: AsyncClient,
@@ -244,6 +254,7 @@ async def test_refresh_token_success_refresh_token_has_valid_expire_time(
244254
)
245255

246256

257+
@pytest.mark.asyncio(loop_scope="session")
247258
async def test_refresh_token_success_new_refresh_token_is_in_db(
248259
client: AsyncClient,
249260
default_user: User,

app/tests/test_auth/test_register_new_user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from fastapi import status
23
from httpx import AsyncClient
34
from sqlalchemy import func, select
@@ -8,6 +9,7 @@
89
from app.models import User
910

1011

12+
@pytest.mark.asyncio(loop_scope="session")
1113
async def test_register_new_user_status_code(
1214
client: AsyncClient,
1315
) -> None:
@@ -22,6 +24,7 @@ async def test_register_new_user_status_code(
2224
assert response.status_code == status.HTTP_201_CREATED
2325

2426

27+
@pytest.mark.asyncio(loop_scope="session")
2528
async def test_register_new_user_creates_record_in_db(
2629
client: AsyncClient,
2730
session: AsyncSession,
@@ -40,6 +43,7 @@ async def test_register_new_user_creates_record_in_db(
4043
assert user_count == 1
4144

4245

46+
@pytest.mark.asyncio(loop_scope="session")
4347
async def test_register_new_user_cannot_create_already_created_user(
4448
client: AsyncClient,
4549
session: AsyncSession,

app/tests/test_users/test_delete_current_user.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from fastapi import status
23
from httpx import AsyncClient
34
from sqlalchemy import select
@@ -7,6 +8,7 @@
78
from app.models import User
89

910

11+
@pytest.mark.asyncio(loop_scope="session")
1012
async def test_delete_current_user_status_code(
1113
client: AsyncClient,
1214
default_user_headers: dict[str, str],
@@ -19,6 +21,7 @@ async def test_delete_current_user_status_code(
1921
assert response.status_code == status.HTTP_204_NO_CONTENT
2022

2123

24+
@pytest.mark.asyncio(loop_scope="session")
2225
async def test_delete_current_user_is_deleted_in_db(
2326
client: AsyncClient,
2427
default_user_headers: dict[str, str],

app/tests/test_users/test_read_current_user.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from fastapi import status
23
from httpx import AsyncClient
34

@@ -8,6 +9,7 @@
89
)
910

1011

12+
@pytest.mark.asyncio(loop_scope="session")
1113
async def test_read_current_user_status_code(
1214
client: AsyncClient, default_user_headers: dict[str, str]
1315
) -> None:
@@ -19,6 +21,7 @@ async def test_read_current_user_status_code(
1921
assert response.status_code == status.HTTP_200_OK
2022

2123

24+
@pytest.mark.asyncio(loop_scope="session")
2225
async def test_read_current_user_response(
2326
client: AsyncClient, default_user_headers: dict[str, str]
2427
) -> None:

app/tests/test_users/test_reset_password.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from fastapi import status
23
from httpx import AsyncClient
34
from sqlalchemy import select
@@ -8,6 +9,7 @@
89
from app.models import User
910

1011

12+
@pytest.mark.asyncio(loop_scope="session")
1113
async def test_reset_current_user_password_status_code(
1214
client: AsyncClient,
1315
default_user_headers: dict[str, str],
@@ -21,6 +23,7 @@ async def test_reset_current_user_password_status_code(
2123
assert response.status_code == status.HTTP_204_NO_CONTENT
2224

2325

26+
@pytest.mark.asyncio(loop_scope="session")
2427
async def test_reset_current_user_password_is_changed_in_db(
2528
client: AsyncClient,
2629
default_user_headers: dict[str, str],

0 commit comments

Comments
 (0)