Explorar o código

Expect logged-in status to be displayed

Benoît Hubert %!s(int64=7) %!d(string=hai) anos
pai
achega
4734982315
Modificáronse 3 ficheiros con 7 adicións e 4 borrados
  1. 5 2
      functional_tests/tests.py
  2. 1 1
      movies/templates/home.html
  3. 1 1
      movies/tests.py

+ 5 - 2
functional_tests/tests.py

@@ -6,7 +6,7 @@ from selenium.common.exceptions import WebDriverException
 import time
 import unittest
 
-MAX_WAIT = 10
+MAX_WAIT = 3
 
 class NewVisitorTest(LiveServerTestCase):
 
@@ -27,7 +27,7 @@ class NewVisitorTest(LiveServerTestCase):
             except (AssertionError, WebDriverException) as e:
                 if time.time() - start_time > MAX_WAIT:
                     raise e
-                time.sleep(0.5)
+                time.sleep(0.2)
 
     def test_can_start_a_list_for_one_user(self):
         # Edith has heard about a cool new online to-do app. She goes
@@ -39,6 +39,9 @@ class NewVisitorTest(LiveServerTestCase):
         header_text = self.browser.find_element_by_tag_name('h1').text
         self.assertIn('Your Movie list', header_text)
 
+        header_text = self.browser.find_element_by_tag_name('h2').text
+        self.assertIn('Not logged-in', header_text)
+
         # She is invited to enter a to-do item straight away
         inputbox = self.browser.find_element_by_id('input-new-movie')
         self.assertEqual(

+ 1 - 1
movies/templates/home.html

@@ -6,6 +6,6 @@
         <input name="movie-title" id="input-new-movie" placeholder="Enter a movie title" />
         {% csrf_token %}
       </form>
-      <h2>Your name: {{ name }}</h2>
+      <h2>{% if user.email %}Logged-in as: {{ user }}{{ user.email }}{% else %}Not logged-in{% endif %}</h2>
   </body>
 </html>

+ 1 - 1
movies/tests.py

@@ -20,7 +20,7 @@ class HomePageTest(TestCase):
         self.assertIn('<title>MovieLib</title>', html)
         self.assertTrue(html.strip().endswith('</html>'))
 
-        self.assertIn('<h2>Your name: Guest</h2>', html)
+        self.assertIn('<h2>Not logged-in</h2>', html)
 
         self.assertTemplateUsed(response, 'home.html')