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
1406568923-practice
Commits
b156ac99
Commit
b156ac99
authored
Sep 19, 2019
by
emil farisan
Browse files
Basic view now returns minimal HTML
parent
82deca8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
lists/tests.py
View file @
b156ac99
from
django.urls
import
resolve
from
django.test
import
TestCase
from
lists.views
import
home_page
from
django.http
import
HttpRequest
class
HomePageTest
(
TestCase
):
def
test_root_url_resolves_to_home_page_view
(
self
):
found
=
resolve
(
'/'
)
self
.
assertEqual
(
found
.
func
,
home_page
)
def
test_home_page_returns_correct_html
(
self
):
request
=
HttpRequest
()
response
=
home_page
(
request
)
self
.
assertTrue
(
response
.
content
.
startswith
(
b
'<html>'
))
self
.
assertIn
(
b
'<title>To-Do lists</title>'
,
response
.
content
)
self
.
assertTrue
(
response
.
content
.
endswith
(
b
'</html>'
))
lists/views.py
View file @
b156ac99
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
# Create your views here.
def
home_page
():
pass
def
home_page
(
request
):
return
HttpResponse
(
'<html><title>To-Do lists</title></html>'
)
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