@@ -151,6 +151,55 @@ class MockUser:
151
151
self .assertEqual (response .url , "/" )
152
152
153
153
154
+ class LoginViewProjectNameTest (TestCase ):
155
+ @override_settings (ANSIBLE_AI_PROJECT_NAME = "Ansible Lightspeed with IBM watsonx Code Assistant" )
156
+ def test_project_name_unchanged_without_next (self ):
157
+ request = RequestFactory ().get ("/login" )
158
+ request .user = AnonymousUser ()
159
+ response = LoginView .as_view ()(request )
160
+ response .render ()
161
+ contents = response .content .decode ()
162
+ self .assertIn ("Log in to Ansible Lightspeed with IBM watsonx Code Assistant" , contents )
163
+
164
+ @override_settings (ANSIBLE_AI_PROJECT_NAME = "Ansible Lightspeed with IBM watsonx Code Assistant" )
165
+ def test_project_name_unchanged_with_different_next (self ):
166
+ request = RequestFactory ().get ("/login?next=/home" )
167
+ request .user = AnonymousUser ()
168
+ response = LoginView .as_view ()(request )
169
+ response .render ()
170
+ contents = response .content .decode ()
171
+ self .assertIn ("Log in to Ansible Lightspeed with IBM watsonx Code Assistant" , contents )
172
+
173
+ @override_settings (ANSIBLE_AI_PROJECT_NAME = "Ansible Lightspeed with IBM watsonx Code Assistant" )
174
+ def test_project_name_modified_with_chatbot_next (self ):
175
+ request = RequestFactory ().get ("/login?next=/chatbot" )
176
+ request .user = AnonymousUser ()
177
+ response = LoginView .as_view ()(request )
178
+ response .render ()
179
+ contents = response .content .decode ()
180
+ self .assertIn ("Log in to Ansible Lightspeed" , contents )
181
+ self .assertNotIn ("Log in to Ansible Lightspeed with IBM watsonx Code Assistant" , contents )
182
+
183
+ @override_settings (ANSIBLE_AI_PROJECT_NAME = "Ansible Lightspeed with IBM watsonx Code Assistant" )
184
+ def test_project_name_modified_with_chatbot_slash_next (self ):
185
+ request = RequestFactory ().get ("/login?next=/chatbot/" )
186
+ request .user = AnonymousUser ()
187
+ response = LoginView .as_view ()(request )
188
+ response .render ()
189
+ contents = response .content .decode ()
190
+ self .assertIn ("Log in to Ansible Lightspeed" , contents )
191
+ self .assertNotIn ("Log in to Ansible Lightspeed with IBM watsonx Code Assistant" , contents )
192
+
193
+ @override_settings (ANSIBLE_AI_PROJECT_NAME = "Ansible AI Connect" )
194
+ def test_project_name_no_change_if_no_watsonx_text (self ):
195
+ request = RequestFactory ().get ("/login?next=/chatbot" )
196
+ request .user = AnonymousUser ()
197
+ response = LoginView .as_view ()(request )
198
+ response .render ()
199
+ contents = response .content .decode ()
200
+ self .assertIn ("Log in to Ansible AI Connect" , contents )
201
+
202
+
154
203
@override_settings (ALLOW_METRICS_FOR_ANONYMOUS_USERS = False )
155
204
class TestMetricsView (APITransactionTestCase ):
156
205
0 commit comments