Fakultas Ilmu Komputer UI

Commit 5825e70c authored by Syahrul Findi's avatar Syahrul Findi
Browse files

Merge branch 'latihan2' into 'master'

Feature: Comment

See merge request !3
parents 908534e9 9768ce91
......@@ -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.text,
'yey, waktunya berlibur'
)
# 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.text,
'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.text,
'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.
......
......@@ -21,5 +21,13 @@
</tr>
{% endfor %}
</table>
{% if items|length > 5 %}
<p id="comment">oh tidak</p>
{% elif items|length > 0 %}
<p id="comment">sibuk tapi santai</p>
{% else %}
<p id="comment">yey, waktunya berlibur</p>
{% endif %}
</body>
</html>
......@@ -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