From 47ea67f37e8e27453b51bb21615cc89fec186248 Mon Sep 17 00:00:00 2001 From: varun kumar Date: Sun, 3 Sep 2023 16:26:06 +0530 Subject: [PATCH] Add testcase for testing signup get_initialmethod --- allauth/account/tests/test_signup.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/allauth/account/tests/test_signup.py b/allauth/account/tests/test_signup.py index ed7c5933e8..f6736087a5 100644 --- a/allauth/account/tests/test_signup.py +++ b/allauth/account/tests/test_signup.py @@ -315,3 +315,16 @@ def test_django_password_validation(self): "password1", ["This password is too short. It must contain at least 9 characters."], ) + + def test_get_initial_with_valid_email(self): + """Test that the email field is populated with a valid email.""" + request = RequestFactory().get("/signup/?email=test@example.com") + from allauth.account.views import signup + + SessionMiddleware(lambda request: None).process_request(request) + request.user = AnonymousUser() + view = signup(request) + view.request = request + self.assertEqual( + view.context_data["view"].get_initial()["email"], "test@example.com" + )