@@ -38,7 +38,25 @@ async def get_by_email(self, email: str):
3838 "hashed_password" : "$2b$12$zqt9Rgv1PzORjG5ghJSb6OSdYrt7f7cLc38a21DgX/DMyqt80AUCi" ,
3939 "is_initialized" : True ,
4040 }
41- if email == "hi2@hi.com" :
41+ # if email == "hi2@hi.com":
42+ # return {
43+ # "_id": "user123",
44+ # "name": "Bob",
45+ # "email": email,
46+ # "scopes": AccessRoles.USER,
47+ # "hashed_password": "$2b$12$zqt9Rgv1PzORjG5ghJSb6OSdYrt7f7cLc38a21DgX/DMyqt80AUCi",
48+ # "is_initialized": False,
49+ # }
50+ # if email == "hi3@hi.com":
51+ # return {
52+ # "_id": "user123",
53+ # "name": "Bob",
54+ # "email": email,
55+ # "scopes": AccessRoles.USER,
56+ # "hashed_password": "$2b$12$zqt9Rgv1PzORjG5ghJSb6OSdYrt7f7cLc38a21DgX/DMyqt80AUCi",
57+ # "is_initialized": False,
58+ # }
59+ if email == "hi4@hi.com" :
4260 return {
4361 "_id" : "user123" ,
4462 "name" : "Bob" ,
@@ -47,17 +65,19 @@ async def get_by_email(self, email: str):
4765 "hashed_password" : "$2b$12$zqt9Rgv1PzORjG5ghJSb6OSdYrt7f7cLc38a21DgX/DMyqt80AUCi" ,
4866 "is_initialized" : False ,
4967 }
68+
5069 async def update_user (self , user_id : str , user_data : UserUpdate ):
5170 MockUpdateResult = MagicMock ()
5271 print (user_id , user_data )
5372 if user_id == "hi@hi.com" or user_id == "hihi@hi.com" :
5473 MockUpdateResult .modified_count = 1
5574 MockUpdateResult .matched_count = 1
5675 return MockUpdateResult
57- if user_id == "hi2 @hi.com" :
76+ if user_id == "hi3 @hi.com" :
5877 MockUpdateResult .modified_count = 0
5978 MockUpdateResult .matched_count = 1
6079 return MockUpdateResult
80+
6181 if user_id == "error@error.com" :
6282 raise Exception ("error" )
6383 MockUpdateResult .modified_count = 0
@@ -145,7 +165,7 @@ async def test__unit_test__update_user(fake_user_repo, monkeypatch):
145165
146166@pytest .mark .asyncio
147167async def test__unit_test__update_user_same_data (fake_user_repo , monkeypatch ):
148- user_new_data = UserUpdate (_id = "hi2 @hi.com" , password = "newpassword" , is_initialized = True , remember_me = True , scopes = AccessRoles .USER )
168+ user_new_data = UserUpdate (_id = "hi3 @hi.com" , password = "newpassword" , is_initialized = True , remember_me = True , scopes = AccessRoles .USER )
149169 result = await update_user (user_new_data , current_user , fake_user_repo )
150170 assert result ["message" ] != None
151171
@@ -252,14 +272,12 @@ async def test__unit_test__update_password_old_password_error(fake_user_repo, mo
252272@pytest .mark .asyncio
253273async def test__unit_test__update_password_is_not_init_with_not_found (fake_user_repo , monkeypatch ):
254274 user_data = UserUpdatePassword (password = "Abc123!@#@js" , current_password = "test_password" )
255- current_user = {"sub" : "hi2@hi.com" }
275+ current_user = {"sub" : "hi4@hi.com" }
276+
256277 with pytest .raises (HTTPException ) as excinfo :
257278 await update_password (user_data , current_user , fake_user_repo )
258279 assert excinfo .value .status_code == 500
259280
260-
261-
262-
263281@pytest .mark .asyncio
264282async def test__unit_test__reset_password (fake_user_repo , monkeypatch ):
265283 user_data = UserForgotPassword (email = "hi@hi.com" )
0 commit comments