diff --git a/tests/emailpassword/test_passwordreset.py b/tests/emailpassword/test_passwordreset.py index e618b0bbf..f684b3290 100644 --- a/tests/emailpassword/test_passwordreset.py +++ b/tests/emailpassword/test_passwordreset.py @@ -119,9 +119,14 @@ async def test_email_validation_checks_in_generate_token_API( json={"formFields": [{"id": "email", "value": invalid_email}]}, ) - assert res.status_code == 200 dict_res = json.loads(res.text) - assert dict_res["status"] == "FIELD_ERROR" + assert res.status_code == 200 if invalid_email == "random" else 400 + if invalid_email == "random": + assert dict_res["status"] == "FIELD_ERROR" + assert dict_res["formFields"][0]["id"] == "email" + assert dict_res["formFields"][0]["error"] == "Email is not valid" + else: + assert dict_res["message"] == "email value must be a string" @mark.asyncio diff --git a/tests/input_validation/test_input_validation.py b/tests/input_validation/test_input_validation.py index 96beec0ea..08728031c 100644 --- a/tests/input_validation/test_input_validation.py +++ b/tests/input_validation/test_input_validation.py @@ -2,6 +2,7 @@ from typing import Any, Dict, List import pytest + from supertokens_python import InputAppInfo, SupertokensConfig, init from supertokens_python.recipe import ( emailpassword, @@ -31,22 +32,6 @@ async def test_init_validation_emailpassword(): ) assert "app_info must be an instance of InputAppInfo" == str(ex.value) - with pytest.raises(ValueError) as ex: - init( - supertokens_config=SupertokensConfig("http://localhost:3567"), - app_info=InputAppInfo( - app_name="SuperTokens Demo", - api_domain="http://api.supertokens.io", - website_domain="http://supertokens.io", - api_base_path="/auth", - ), - framework="fastapi", - recipe_list=[ - emailpassword.init(sign_up_feature="sign up"), # type: ignore - ], - ) - assert "sign_up_feature must be of type InputSignUpFeature or None" == str(ex.value) - with pytest.raises(ValueError) as ex: init( supertokens_config=SupertokensConfig("http://localhost:3567"), @@ -67,22 +52,6 @@ async def test_init_validation_emailpassword(): == str(ex.value) ) - with pytest.raises(ValueError) as ex: - init( - supertokens_config=SupertokensConfig("http://localhost:3567"), - app_info=InputAppInfo( - app_name="SuperTokens Demo", - api_domain="http://api.supertokens.io", - website_domain="http://supertokens.io", - api_base_path="/auth", - ), - framework="fastapi", - recipe_list=[ - emailpassword.init(override="override"), # type: ignore - ], - ) - assert "override must be of type InputOverrideConfig or None" == str(ex.value) - async def get_email_for_user_id(_: str, __: Dict[str, Any]): return GetEmailForUserIdOkResult("foo@example.com") @@ -307,7 +276,9 @@ async def send_email( clients=[ thirdparty.ProviderClientConfig( client_id=os.environ.get("GOOGLE_CLIENT_ID"), # type: ignore - client_secret=os.environ.get("GOOGLE_CLIENT_SECRET"), # type: ignore + client_secret=os.environ.get( + "GOOGLE_CLIENT_SECRET" + ), # type: ignore ) ], ) @@ -318,7 +289,9 @@ async def send_email( clients=[ thirdparty.ProviderClientConfig( client_id=os.environ.get("FACEBOOK_CLIENT_ID"), # type: ignore - client_secret=os.environ.get("FACEBOOK_CLIENT_SECRET"), # type: ignore + client_secret=os.environ.get( + "FACEBOOK_CLIENT_SECRET" + ), # type: ignore ) ], ) @@ -329,7 +302,9 @@ async def send_email( clients=[ thirdparty.ProviderClientConfig( client_id=os.environ.get("GITHUB_CLIENT_ID"), # type: ignore - client_secret=os.environ.get("GITHUB_CLIENT_SECRET"), # type: ignore + client_secret=os.environ.get( + "GITHUB_CLIENT_SECRET" + ), # type: ignore ) ], ) @@ -365,6 +340,9 @@ async def test_init_validation_session(): api_base_path="/auth", ), framework="fastapi", + # NOTE: Type is ignored in the following line because that + # is what is being tested for so that the SDK throws an error + # on invalid type. recipe_list=[session.init(error_handlers="error handlers")], # type: ignore ) assert "error_handlers must be an instance of ErrorHandlers or None" == str( @@ -401,6 +379,9 @@ async def test_init_validation_thirdparty(): ), framework="fastapi", recipe_list=[ + # NOTE: Type is ignored in the following line because that + # is what is being tested for so that the SDK throws an error + # on invalid type. thirdparty.init(sign_in_and_up_feature="sign in up") # type: ignore ], )