Fakultas Ilmu Komputer UI

Commit f790efe9 authored by Muhammad Ilham Peruzzi's avatar Muhammad Ilham Peruzzi
Browse files

Merge branch 'testinggoat/ch4-5' into 'master'

Testinggoat/ch4 5

See merge request !2
parents 57cf06a5 a24a5cc5
......@@ -21,7 +21,7 @@ class NewVisitorTest(unittest.TestCase):
# Edith has heard about a cool new online to-do app. She goes
# to check out its homepage
self.browser.get('http://localhost:8000')
# She notices the page title and header mention to-do lists
self.assertIn('To-Do', self.browser.title)
header_text = self.browser.find_element_by_tag_name('h1').text
......@@ -56,7 +56,7 @@ class NewVisitorTest(unittest.TestCase):
# 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.
self.fail('Finish the test!')
#self.fail('Finish the test!')
# She visits that URL - her to-do list is still there.
......@@ -65,11 +65,18 @@ class NewVisitorTest(unittest.TestCase):
def test_my_name_exist_in_homepage(self):
self.browser.get('http://localhost:8000')
assert 'Muhammad Ilham Peruzzi' in self.browser.page_source
def test_homepage_have_homepage_text_and_my_biography(self):
self.browser.get('http://localhost:8000')
assert 'Homepage' in self.browser.page_source
assert 'Bio' in self.browser.page_source
def test_text_automatic_comment(self):
self.browser.get('http://localhost:8000')
for i in range(8):
import time
time.sleep(3)
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Activity' + str(i))
inputbox.send_keys(Keys.ENTER)
assert 'oh tidak' in self.browser.page_source
if __name__ == '__main__':
unittest.main(warnings='ignore')
......@@ -16,12 +16,19 @@
<input name="item_text" id="id_new_item" placeholder="Enter a to-do item" />
{% csrf_token %}
</form>
{% if items|length == 0 %}
<p>yey, waktunya berlibur</p>
{% elif items|length < 5 %}
<p>sibuk tapi santai</p>
{% else %}
<p>oh tidak</p>
{% endif %}
<table id="id_list_table">
{% for item in items %}
<tr>
<td>{{ forloop.counter }}: {{ item.text }}</td>
</tr>
ss{% endfor %}
{% endfor %}
</table>
</body>
</html>
\ No newline at end of file
......@@ -87,4 +87,32 @@ class HomePageTest(TestCase):
request = HttpRequest()
response = home_page(request)
self.assertIn('itemey 1', response.content.decode())
self.assertIn('itemey 2', response.content.decode())
\ No newline at end of file
self.assertIn('itemey 2', response.content.decode())
def test_automatic_comment_when_no_items(self):
self.assertEqual(Item.objects.count(), 0)
request = HttpRequest()
response = home_page(request)
self.assertIn('yey, waktunya berlibur', response.content.decode())
def test_automatic_comment_when_to_do_have_less_five_items(self):
Item.objects.create(text='Activity 1')
Item.objects.create(text='Activity 2')
self.assertEqual(Item.objects.count(), 2)
request = HttpRequest()
response = home_page(request)
self.assertIn('Activity 1', response.content.decode())
self.assertIn('sibuk tapi santai', response.content.decode())
def test_automatic_comment_when_to_do_have_more_than_or_equal_five_items(self):
Item.objects.create(text='Activity 1')
Item.objects.create(text='Activity 2')
Item.objects.create(text='Activity 3')
Item.objects.create(text='Activity 4')
Item.objects.create(text='Activity 5')
Item.objects.create(text='Activity 6')
self.assertEqual(Item.objects.count(), 6)
request = HttpRequest()
response = home_page(request)
self.assertIn('Activity 6', response.content.decode())
self.assertIn('oh tidak', response.content.decode())
\ No newline at end of file
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