Fakultas Ilmu Komputer UI

Commit 7594a3a8 authored by Syahrul Ardiansyah's avatar Syahrul Ardiansyah
Browse files

Add test to check right comment

parent 5c74b50d
......@@ -30,6 +30,13 @@ class NewVisitorTest(unittest.TestCase):
header_text = self.browser.find_element_by_tag_name('h1').text
self.assertIn('Syahrul Findi Ardiansyah', header_text)
# She check the comment when there is no item
comment = self.browser.find_element_by_id('comment')
self.assertEqual(
comment,
'yey, waktunya libur'
)
# She is invited to enter a to-do item straight away
inputbox = self.browser.find_element_by_id('id_new_item')
self.assertEqual(
......@@ -60,6 +67,27 @@ class NewVisitorTest(unittest.TestCase):
self.check_for_row_in_list_table(
'2: Use peacock feathers to make a fly')
# She check the comment when there is few items
comment = self.browser.find_element_by_id('comment')
self.assertEqual(
comment,
'sibuk tapi santai'
)
# Add additional items to change the comment
for i in range(4):
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Additional item %d' % i)
inputbox.send_keys(Keys.ENTER)
time.sleep(1)
# She check the comment when there is many items
comment = self.browser.find_element_by_id('comment')
self.assertEqual(
comment,
'oh tidak'
)
# 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
# explanatory text to that effect.
......
......@@ -50,6 +50,24 @@ class HomePageTest(TestCase):
self.assertIn('itemey 1', response.content.decode())
self.assertIn('itemey 2', response.content.decode())
def test_home_page_returns_correct_comment_on_empty_items(self):
response = self.client.get('/')
self.assertIn('yey, waktunya berlibur', response.content.decode())
def test_home_page_returns_correct_comment_on_few_items(self):
for i in range(2):
Item.objects.create(text='itemey %d' % i)
response = self.client.get('/')
self.assertIn('sibuk tapi santai', response.content.decode())
def test_home_page_returns_correct_comment_on_many_items(self):
for i in range(6):
Item.objects.create(text='itemey %d' % i)
response = self.client.get('/')
self.assertIn('oh tidak', response.content.decode())
class ItemModelTest(TestCase):
def test_saving_and_retrieving_items(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment