Compare commits
No commits in common. "ac7a1a70e12c174635e8c0df256a87c7b730069b" and "9bacbfef4cc06e13b015e975003563d943a7998d" have entirely different histories.
ac7a1a70e1
...
9bacbfef4c
|
@ -11,11 +11,6 @@ class NewVisitorTest(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
self.browser.quit()
|
||||
|
||||
def check_for_row_in_list_table(self, row_text):
|
||||
table = self.browser.find_element_by_id('id_list_table')
|
||||
rows = table.find_elements_by_tag_name('tr')
|
||||
self.assertIn(row_text, [row.text for row in rows])
|
||||
|
||||
def test_can_start_a_list_and_retrieve_it_later(self):
|
||||
# Edith has heard about a cool new online to-do app. She goes
|
||||
# to check out its homepage
|
||||
|
@ -41,7 +36,9 @@ class NewVisitorTest(unittest.TestCase):
|
|||
# "1: Buy peacock feathers" as an item in a to-do list
|
||||
inputbox.send_keys(Keys.ENTER)
|
||||
time.sleep(1)
|
||||
self.check_for_row_in_list_table('1: Buy peacock feathers')
|
||||
table = self.browser.find_element_by_id('id_list_table')
|
||||
rows = table.find_elements_by_tag_name('tr')
|
||||
# self.assertTrue('1: Buy peacock feathers', [row.text for row in rows])
|
||||
|
||||
# There is still a text box inviting her to add another item. She
|
||||
# enters "Use peacock feathers to make a fly" (Edith is very methodical)
|
||||
|
@ -51,8 +48,14 @@ class NewVisitorTest(unittest.TestCase):
|
|||
time.sleep(1)
|
||||
|
||||
# The page updates again, and now shows both items on her list
|
||||
self.check_for_row_in_list_table('1: Buy peacock feathers')
|
||||
self.check_for_row_in_list_table('2: Use peacock feathers to make a fly')
|
||||
table = self.browser.find_element_by_id('id_list_table')
|
||||
rows = table.find_elements_by_tag_name('tr')
|
||||
print(rows)
|
||||
self.assertIn('1: Buy peacock feathers', [row.text for row in rows])
|
||||
self.assertIn(
|
||||
'2: Use peacock feathers to make a fly',
|
||||
[row.text for row in rows]
|
||||
)
|
||||
|
||||
# Edith wonders whether the site will remember her list. Then she sees
|
||||
# that the site has generated a unique URL for her -- there is some
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
class Item(models.Model):
|
||||
text = models.TextField(default='')
|
||||
# Create your models here.
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.urls import resolve
|
|||
from django.http import HttpRequest
|
||||
|
||||
from lists.views import home_page
|
||||
from lists.models import Item
|
||||
|
||||
class HomePageTest(TestCase):
|
||||
|
||||
|
@ -20,22 +19,3 @@ class HomePageTest(TestCase):
|
|||
response = self.client.post('/', data={'item_text': 'A new list item'})
|
||||
self.assertIn('A new list item', response.content.decode())
|
||||
self.assertTemplateUsed(response, 'home.html')
|
||||
|
||||
class ItemModelTest(TestCase):
|
||||
|
||||
def test_saving_and_retrieving_items(self):
|
||||
first_item = Item() # Create an object
|
||||
first_item.text = 'The first (ever) list item' # Assign attributes
|
||||
first_item.save() # Calling .save() function
|
||||
|
||||
second_item = Item()
|
||||
second_item.text = 'Item the second'
|
||||
second_item.save()
|
||||
|
||||
saved_items = Item.objects.all()
|
||||
self.assertEqual(saved_items.count(), 2)
|
||||
|
||||
first_saved_item = saved_items[0]
|
||||
second_saved_item = saved_items[1]
|
||||
self.assertEqual(first_saved_item.text, 'The first (ever) list item')
|
||||
self.assertEqual(second_saved_item.text, 'Item the second')
|
Loading…
Reference in New Issue