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
ppl-fasilkom-ui
PPL Sosial
bisago
bisago-be
Commits
4b527286
Verified
Commit
4b527286
authored
Mar 20, 2021
by
Muhammad Ariq Basyar
Browse files
remove repeated code at base test, make more general method
parent
2298e07c
Pipeline
#64624
passed with stages
in 7 minutes
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
informasi_fasilitas/test_base.py
View file @
4b527286
...
...
@@ -141,29 +141,26 @@ class InformasiFasilitasTest(TestCase):
dislike_test
.
save
()
return
dislike_test
def
client_
user_token
(
self
):
Client
().
post
(
REGISTER
,
self
.
user_
pos
t
)
test_user
=
User
.
objects
.
get
(
username
=
self
.
user_
pos
t
[
"
email
"
])
def
get_
client_
from_user
(
self
,
user_dict
):
Client
().
post
(
REGISTER
,
user_
dic
t
)
test_user
=
User
.
objects
.
get
(
username
=
user_
dic
t
[
'
email
'
])
test_user
.
is_active
=
True
test_user
.
save
()
token_response
=
Client
().
post
(
TOKEN_AUTH
,
{
'username'
:
self
.
user_
pos
t
[
"email"
],
'password'
:
self
.
user_
pos
t
[
"password"
]})
token_response
=
Client
().
post
(
TOKEN_AUTH
,
{
'username'
:
user_
dic
t
[
"email"
],
'password'
:
user_
dic
t
[
"password"
]})
content
=
json
.
loads
(
token_response
.
content
.
decode
(
'utf-8'
))
token
=
content
[
'token'
]
client
=
Client
(
HTTP_AUTHORIZATION
=
TOKEN_SUFFIX
+
token
)
return
client
def
client_user_token
(
self
):
return
self
.
get_client_from_user
(
self
.
user_post
)
def
client_user_token2
(
self
):
Client
().
post
(
REGISTER
,
self
.
user_post
)
test_user
=
User
.
objects
.
get
(
username
=
self
.
default_username_email
)
test_user
.
is_active
=
True
test_user
.
save
()
token_response
=
Client
().
post
(
TOKEN_AUTH
,
{
'username'
:
self
.
default_username_email
,
'password'
:
self
.
default_password
})
content
=
json
.
loads
(
token_response
.
content
.
decode
(
'utf-8'
))
token
=
content
[
'token'
]
client
=
Client
(
HTTP_AUTHORIZATION
=
TOKEN_SUFFIX
+
token
)
return
client
return
self
.
get_client_from_user
({
'name'
:
self
.
default_username_email
,
'email'
:
self
.
default_username_email
,
'phone_number'
:
self
.
default_no_telp
,
'password'
:
self
.
default_password
})
class
InformasiFasilitasViewTest
(
InformasiFasilitasTest
):
...
...
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