Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Collection of Practice
2019
1506757352-practice
Commits
5825e70c
Commit
5825e70c
authored
Sep 24, 2019
by
Syahrul Findi
Browse files
Merge branch 'latihan2' into 'master'
Feature: Comment See merge request
!3
parents
908534e9
9768ce91
Changes
3
Hide whitespace changes
Inline
Side-by-side
functional_test.py
View file @
5825e70c
...
...
@@ -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.
...
...
latihan2/templates/home.html
View file @
5825e70c
...
...
@@ -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>
latihan2/tests.py
View file @
5825e70c
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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