Преглед на файлове

Expect logged-in status to be displayed

Benoît Hubert преди 7 години
родител
ревизия
4734982315
променени са 3 файла, в които са добавени 7 реда и са изтрити 4 реда
  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 time
 import unittest
 import unittest
 
 
-MAX_WAIT = 10
+MAX_WAIT = 3
 
 
 class NewVisitorTest(LiveServerTestCase):
 class NewVisitorTest(LiveServerTestCase):
 
 
@@ -27,7 +27,7 @@ class NewVisitorTest(LiveServerTestCase):
             except (AssertionError, WebDriverException) as e:
             except (AssertionError, WebDriverException) as e:
                 if time.time() - start_time > MAX_WAIT:
                 if time.time() - start_time > MAX_WAIT:
                     raise e
                     raise e
-                time.sleep(0.5)
+                time.sleep(0.2)
 
 
     def test_can_start_a_list_for_one_user(self):
     def test_can_start_a_list_for_one_user(self):
         # Edith has heard about a cool new online to-do app. She goes
         # 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
         header_text = self.browser.find_element_by_tag_name('h1').text
         self.assertIn('Your Movie list', header_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
         # She is invited to enter a to-do item straight away
         inputbox = self.browser.find_element_by_id('input-new-movie')
         inputbox = self.browser.find_element_by_id('input-new-movie')
         self.assertEqual(
         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" />
         <input name="movie-title" id="input-new-movie" placeholder="Enter a movie title" />
         {% csrf_token %}
         {% csrf_token %}
       </form>
       </form>
-      <h2>Your name: {{ name }}</h2>
+      <h2>{% if user.email %}Logged-in as: {{ user }}{{ user.email }}{% else %}Not logged-in{% endif %}</h2>
   </body>
   </body>
 </html>
 </html>

+ 1 - 1
movies/tests.py

@@ -20,7 +20,7 @@ class HomePageTest(TestCase):
         self.assertIn('<title>MovieLib</title>', html)
         self.assertIn('<title>MovieLib</title>', html)
         self.assertTrue(html.strip().endswith('</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')
         self.assertTemplateUsed(response, 'home.html')