Fakultas Ilmu Komputer UI

Commit abd350fe authored by Kevin Albert Simanjuntak's avatar Kevin Albert Simanjuntak
Browse files

[green] refactor some test and implement the test

parent 396f2b65
Pipeline #20871 passed with stage
in 1 minute and 26 seconds
No preview for this file type
......@@ -40,11 +40,28 @@ class NewVisitorTest(unittest.TestCase):
inputbox.send_keys(Keys.ENTER)
time.sleep(5)
self.check_comment_based_on_total_list()
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Buy peacock')
inputbox.send_keys(Keys.ENTER)
time.sleep(5)
self.check_comment_based_on_total_list()
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Buy feathers')
inputbox.send_keys(Keys.ENTER)
time.sleep(5)
self.check_comment_based_on_total_list()
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('feathers')
inputbox.send_keys(Keys.ENTER)
time.sleep(5)
self.check_comment_based_on_total_list()
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Buy')
inputbox.send_keys(Keys.ENTER)
time.sleep(5)
self.check_comment_based_on_total_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')
self.assertEqual(3, len(rows))
#comment = self.browser.find_element_by_id('comment').text
#self.assertIn('oakwowakkoaw', comment)
def check_comment_based_on_total_list(self):
......
......@@ -13,5 +13,7 @@
<tr><td>{{ forloop.counter }}: {{ item.text }}</td></tr>
{% endfor %}
</table>
<h2 id="comment">{{comment}}</h2>
</body>
</html>
\ No newline at end of file
......@@ -2,9 +2,18 @@ from django.shortcuts import redirect, render
from lists.models import Item
def home_page(request):
if request.method == 'POST':
Item.objects.create(text=request.POST['item_text'])
return redirect('/homepage/')
response={}
if request.method == 'POST':
Item.objects.create(text=request.POST['item_text'])
return redirect('/homepage/')
items = Item.objects.all()
return render(request, 'home.html', {'items': items})
\ No newline at end of file
items = Item.objects.all()
response['items'] = items
if not items:
comment = 'yey, waktunya berlibur'
elif len(items)<5:
comment = 'sibuk tapi santai'
else:
comment = 'oh tidak'
response['comment'] = comment
return render(request, 'home.html', response)
\ 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