Fakultas Ilmu Komputer UI

Commit 5bf84692 authored by Muhammad Ilham Peruzzi's avatar Muhammad Ilham Peruzzi
Browse files

add test case that strongly kills mutant, pipeline fail because of that

parent 5dffbf04
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import unittest
import environ
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from unittest import skip
from .base import FunctionalTest
class AutomaticCommentTest(FunctionalTest):
def test_can_start_a_list_and_retrieve_it_later(self):
self.browser.get(self.live_server_url)
inputbox = self.browser.find_element_by_id('id_new_item')
self.assertEqual(
inputbox.get_attribute('placeholder'),
'Enter a to-do item'
)
inputbox.send_keys('Buy peacock feathers')
inputbox.send_keys(Keys.ENTER)
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Use peacock feathers to make a fly')
inputbox.send_keys(Keys.ENTER)
page_text = self.browser.find_element_by_tag_name('body').text
self.assertIn('sibuk tapi santai', page_text)
for i in range(6):
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Activity' + str(i))
inputbox.send_keys(Keys.ENTER)
page_text = self.browser.find_element_by_tag_name('body').text
self.assertIn('oh tidak', page_text)
#assert 'oh tidak' in self.browser.page_source
edith_list_url = self.browser.current_url
self.assertRegex(edith_list_url, '/lists/.+')
self.wait_for_row_in_list_table('1: Buy peacock feathers')
# Now a new user, Francis, comes along to the site.
## We use a new browser session to make sure that no information
## of Edith's is coming through from cookies etc #
self.browser.get(self.live_server_url)
page_text = self.browser.find_element_by_tag_name('body').text
self.assertNotIn('Buy peacock feathers', page_text)
self.assertNotIn('make a fly', page_text)
# Francis starts a new list by entering a new item. He
# is less interesting than Edith...
inputbox = self.browser.find_element_by_id('id_new_item')
inputbox.send_keys('Buy milk')
inputbox.send_keys(Keys.ENTER)
# Francis gets his own unique URL
francis_list_url = self.browser.current_url
self.assertRegex(francis_list_url, '/lists/.+')
self.assertNotEqual(francis_list_url, edith_list_url)
# Again, there is no trace of Edith's list
page_text = self.browser.find_element_by_tag_name('body').text
self.assertNotIn('Buy peacock feathers', page_text)
self.assertIn('Buy milk', page_text)
# Satisfied, they both go back to sleep
\ No newline at end of file
......@@ -5,47 +5,18 @@
{% block form_action %}/lists/{{ list.id }}/add_item{% endblock %}
{% block table %}
<!-- {% if list.item_set.all|length == 0 %}
<p>yey, waktunya berlibur</p>
{% elif list.item_set.all|length < 5 %}
<p>sibuk tapi santai</p>
{% else %}
<p>oh tidak</p>
{% endif %}
<table id="id_list_table" class="table">
{% for item in list.item_set.all %}
<tr><td>{{ forloop.counter }}: {{ item.text }}</td></tr>
{% endfor %}
</table>
{% endblock %} -->
<!--Mutant 1-->
{% if list.item_set.all|length != 0 %}
<p>yey, waktunya berlibur</p>
{% elif list.item_set.all|length < 5 %}
<p>sibuk tapi santai</p>
{% else %}
<p>oh tidak</p>
{% endif %}
<table id="id_list_table" class="table">
{% for item in list.item_set.all %}
<tr><td>{{ forloop.counter }}: {{ item.text }}</td></tr>
{% endfor %}
</table>
{% endblock %}
<!--Mutant 2-->
<!-- {% if list.item_set.all|length == 0 %}
{% if list.item_set.all|length == 0 %}
<div id="comment">
<p>yey, waktunya berlibur</p>
{% elif list.item_set.all|length > 5 %}
<p>sibuk tapi santai</p>
{% else %}
<p>oh tidak</p>
{% endif %}
</div>
<table id="id_list_table" class="table">
{% for item in list.item_set.all %}
<tr><td>{{ forloop.counter }}: {{ item.text }}</td></tr>
{% endfor %}
</table>
{% endblock %}
-->
\ 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