Skip to content

Commit 6e4bfa0

Browse files
committed
fix: remove unnecessary session.commit() calls in user tests
1 parent a18ebf5 commit 6e4bfa0

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

tests/routers/test_users.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,13 @@ def test_cannot_get_anonymous_user(client, setup_router_db, session, anonymous_a
5252
response_value = response.json()
5353
assert "Could not validate credentials" in response_value["detail"]
5454

55-
# Some lingering db transaction holds this test open unless it is explicitly closed.
56-
session.commit()
57-
5855

5956
def test_get_current_user(client, setup_router_db, session):
6057
response = client.get("/api/v1/users/me")
6158
assert response.status_code == 200
6259
response_value = response.json()
6360
assert response_value["orcidId"] == TEST_USER["username"]
6461

65-
# Some lingering db transaction holds this test open unless it is explicitly closed.
66-
session.commit()
67-
6862

6963
def test_get_current_admin_user(client, admin_app_overrides, setup_router_db, session):
7064
with DependencyOverrider(admin_app_overrides):
@@ -75,9 +69,6 @@ def test_get_current_admin_user(client, admin_app_overrides, setup_router_db, se
7569
assert response_value["orcidId"] == ADMIN_USER["username"]
7670
assert response_value["roles"] == ["admin"]
7771

78-
# Some lingering db transaction holds this test open unless it is explicitly closed.
79-
session.commit()
80-
8172

8273
def test_cannot_impersonate_admin_user_as_default_user(client, setup_router_db, session):
8374
# NOTE: We can't mock JWTBearer directly because the object is created when the `get_current_user` function is called.
@@ -100,9 +91,6 @@ def test_cannot_impersonate_admin_user_as_default_user(client, setup_router_db,
10091
assert response.status_code == 403
10192
assert response.json()["detail"] in "This user is not a member of the requested acting role."
10293

103-
# Some lingering db transaction holds this test open unless it is explicitly closed.
104-
session.commit()
105-
10694

10795
def test_cannot_fetch_single_user_as_anonymous_user(client, setup_router_db, session, anonymous_app_overrides):
10896
with DependencyOverrider(anonymous_app_overrides):
@@ -111,18 +99,12 @@ def test_cannot_fetch_single_user_as_anonymous_user(client, setup_router_db, ses
11199
assert response.status_code == 401
112100
assert response.json()["detail"] in "Could not validate credentials"
113101

114-
# Some lingering db transaction holds this test open unless it is explicitly closed.
115-
session.commit()
116-
117102

118103
def test_cannot_fetch_single_user_as_normal_user(client, setup_router_db, session):
119104
response = client.get("/api/v1/users/2")
120105
assert response.status_code == 403
121106
assert response.json()["detail"] in "You are not authorized to use this feature"
122107

123-
# Some lingering db transaction holds this test open unless it is explicitly closed.
124-
session.commit()
125-
126108

127109
def test_can_fetch_single_user_as_admin_user(client, setup_router_db, session, admin_app_overrides):
128110
with DependencyOverrider(admin_app_overrides):
@@ -132,9 +114,6 @@ def test_can_fetch_single_user_as_admin_user(client, setup_router_db, session, a
132114
response_value = response.json()
133115
assert response_value["orcidId"] == EXTRA_USER["username"]
134116

135-
# Some lingering db transaction holds this test open unless it is explicitly closed.
136-
session.commit()
137-
138117

139118
def test_fetching_nonexistent_user_as_admin_raises_exception(client, setup_router_db, session, admin_app_overrides):
140119
with DependencyOverrider(admin_app_overrides):
@@ -144,9 +123,6 @@ def test_fetching_nonexistent_user_as_admin_raises_exception(client, setup_route
144123
response_value = response.json()
145124
assert "user profile with ID 0 not found" in response_value["detail"]
146125

147-
# Some lingering db transaction holds this test open unless it is explicitly closed.
148-
session.commit()
149-
150126

151127
def test_anonymous_user_cannot_update_self(client, setup_router_db, anonymous_app_overrides):
152128
user_update = TEST_USER.copy()

0 commit comments

Comments
 (0)