Skip to content

Commit

Permalink
updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Dec 5, 2024
1 parent 8b13393 commit 6eb5898
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,15 @@ async def get_me(self) -> Profile:
@_exception_mapper(_PROFILE_STATUS_MAP)
async def update_me(self, *, profile_update: ProfileUpdate) -> Profile:

update = WebProfileUpdate(
update = WebProfileUpdate.model_construct(
_fields_set=profile_update.model_fields_set,
first_name=profile_update.first_name,
last_name=profile_update.last_name,
)

response = await self.client.patch(
"/me",
json=update.model_dump(exclude_none=True, exclude_unset=True),
json=update.model_dump(exclude_unset=True),
cookies=self.session_cookies,
)
response.raise_for_status()
Expand Down
8 changes: 4 additions & 4 deletions services/api-server/tests/unit/_with_db/test_api_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def mocked_webserver_service_api(app: FastAPI):
) as respx_mock:
# NOTE: webserver-api uses the same schema as api-server!
# in-memory fake data
me = WebProfileGet.model_json_schema()["examples"][0]
me: dict = WebProfileGet.model_json_schema()["examples"][0]
me["first_name"] = "James"
me["last_name"] = "Maxwell"

def _get_me(request):
return httpx.Response(status.HTTP_200_OK, json={"data": me})
Expand All @@ -43,12 +45,10 @@ def _update_me(request: httpx.Request):
return httpx.Response(status.HTTP_200_OK, json={"data": me})

respx_mock.get("/me", name="get_me").mock(side_effect=_get_me)
respx_mock.put("/me", name="update_me").mock(side_effect=_update_me)
respx_mock.patch("/me", name="update_me").mock(side_effect=_update_me)

yield respx_mock

del me


async def test_get_profile(
client: httpx.AsyncClient,
Expand Down

0 comments on commit 6eb5898

Please sign in to comment.