@@ -119,13 +119,13 @@ async def test_patch_user_success(self, mock_db, current_user_dict, sample_user_
119119 username = current_user_dict ["username" ]
120120 user_update = UserUpdate (name = "New Name" )
121121
122- # Convert the UserRead model to a dictionary for the mock
122+
123123 user_dict = sample_user_read .model_dump ()
124124 user_dict ["username" ] = username
125125
126126 with patch ("src.app.api.v1.users.crud_users" ) as mock_crud :
127- mock_crud .get = AsyncMock (return_value = user_dict ) # Return dict instead of UserRead
128- mock_crud .exists = AsyncMock (return_value = False ) # No conflicts
127+ mock_crud .get = AsyncMock (return_value = user_dict )
128+ mock_crud .exists = AsyncMock (return_value = False )
129129 mock_crud .update = AsyncMock (return_value = None )
130130
131131 result = await patch_user (Mock (), user_update , username , current_user_dict , mock_db )
@@ -138,12 +138,11 @@ async def test_patch_user_forbidden(self, mock_db, current_user_dict, sample_use
138138 """Test user update when user tries to update another user."""
139139 username = "different_user"
140140 user_update = UserUpdate (name = "New Name" )
141- # Convert the UserRead model to a dictionary for the mock
142141 user_dict = sample_user_read .model_dump ()
143142 user_dict ["username" ] = username
144143
145144 with patch ("src.app.api.v1.users.crud_users" ) as mock_crud :
146- mock_crud .get = AsyncMock (return_value = user_dict ) # Return dict instead of UserRead
145+ mock_crud .get = AsyncMock (return_value = user_dict )
147146
148147 with pytest .raises (ForbiddenException ):
149148 await patch_user (Mock (), user_update , username , current_user_dict , mock_db )
0 commit comments