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
1606885025-practice
Commits
2fb56068
Commit
2fb56068
authored
Nov 21, 2019
by
Rani Lasma Uli
Browse files
de-spike
parent
a49d9848
Changes
3
Hide whitespace changes
Inline
Side-by-side
functional_tests/base.py
View file @
2fb56068
...
...
@@ -17,18 +17,18 @@ class FunctionalTest(StaticLiveServerTestCase):
self
.
options
.
add_argument
(
'--dns-prefetch-disable'
)
self
.
options
.
add_argument
(
'--no-sandbox'
)
self
.
options
.
add_argument
(
'--headless'
)
self
.
options
.
add_argument
(
'disable-gpu'
)
self
.
options
.
add_argument
(
"--disable-gpu"
)
self
.
options
.
add_argument
(
"--disable-extensions"
)
self
.
createBrowserInstance
()
def
createBrowserInstance
(
self
):
try
:
self
.
browser
=
webdriver
.
Chrome
(
options
=
self
.
options
)
except
WebDriverException
:
# linux
self
.
browser
=
webdriver
.
Chrome
(
'./chromedriver'
,
options
=
self
.
options
)
self
.
browser
=
webdriver
.
Firefox
()
# try:
# self.browser = webdriver.Chrome(options=self.options)
# except WebDriverException:
# # linux
# self.browser = webdriver.Chrome('./chromedriver',
# options=self.options)
self
.
browser
.
implicitly_wait
(
3
)
...
...
functional_tests/test_login.py
0 → 100644
View file @
2fb56068
from
django.core
import
mail
from
selenium.webdriver.common.keys
import
Keys
import
re
from
.base
import
FunctionalTest
TEST_EMAIL
=
'edith@example.com'
SUBJECT
=
'Your login link for Superlists'
class
LoginTest
(
FunctionalTest
):
def
test_can_get_email_link_to_log_in
(
self
):
# Edith goes to the awesome superlists site
# and notices a "Log in" section in the navbar for the first time
# It's telling her to enter her email address, so she does
self
.
browser
.
get
(
self
.
live_server_url
)
self
.
browser
.
find_element_by_name
(
'email'
).
send_keys
(
TEST_EMAIL
)
self
.
browser
.
find_element_by_name
(
'email'
).
send_keys
(
Keys
.
ENTER
)
# A message appears telling her an email has been sent
self
.
wait_for
(
lambda
:
self
.
assertIn
(
'Check your email'
,
self
.
browser
.
find_element_by_tag_name
(
'body'
).
text
))
# She checks her email and finds a message
email
=
mail
.
outbox
[
0
]
self
.
assertIn
(
TEST_EMAIL
,
email
.
to
)
self
.
assertEqual
(
email
.
subject
,
SUBJECT
)
# It has a url link in it
self
.
assertIn
(
'Use this link to log in'
,
email
.
body
)
url_search
=
re
.
search
(
r
'http://.+/.+$'
,
email
.
body
)
if
not
url_search
:
self
.
fail
(
f
'Could not find url in email body:
\n
{
email
.
body
}
'
)
url
=
url_search
.
group
(
0
)
self
.
assertIn
(
self
.
live_server_url
,
url
)
# she clicks it
self
.
browser
.
get
(
url
)
# she is logged in!
self
.
wait_for
(
lambda
:
self
.
browser
.
find_element_by_link_text
(
'Log out'
)
)
navbar
=
self
.
browser
.
find_element_by_css_selector
(
'.navbar'
)
self
.
assertIn
(
TEST_EMAIL
,
navbar
.
text
)
\ No newline at end of file
lists/migrations/0003_auto_20191121_1714.py
0 → 100644
View file @
2fb56068
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-11-21 10:14
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'lists'
,
'0002_item_text'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'item'
,
name
=
'text'
,
field
=
models
.
TextField
(),
),
]
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