Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Collection of Practice
2019
1606835595-practice
Commits
abd350fe
Commit
abd350fe
authored
Sep 25, 2019
by
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
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
db.sqlite3
View file @
abd350fe
No preview for this file type
functional_tests.py
View file @
abd350fe
...
...
@@ -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
):
...
...
lists/__pycache__/tests.cpython-37.pyc
View file @
abd350fe
No preview for this file type
lists/__pycache__/views.cpython-37.pyc
View file @
abd350fe
No preview for this file type
lists/templates/home.html
View file @
abd350fe
...
...
@@ -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
lists/views.py
View file @
abd350fe
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment