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
ppl-fasilkom-ui
PPL Sosial
bisago
bisago-be
Commits
e659f0f0
Verified
Commit
e659f0f0
authored
Mar 18, 2021
by
Muhammad Ariq Basyar
Browse files
[REFACTOR] remove unnecessary test, modified wrong tests
parent
6e6c5ec6
Pipeline
#64513
failed with stages
in 10 minutes and 24 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
informasi_fasilitas/test_base.py
View file @
e659f0f0
...
...
@@ -6,7 +6,7 @@ from django.urls import reverse, path, include
from
.models
import
Lokasi
,
Fasilitas
,
Komentar
,
KURSI_RODA
,
Likes
,
Dislikes
NOT_NULL_CONSTRAINT_FAILED_MESSAGE
=
'
null
'
NOT_NULL_CONSTRAINT_FAILED_MESSAGE
=
'
NOT NULL constraint failed
'
REGISTER
=
'/api/register/'
TOKEN_AUTH
=
'/api-token-auth/'
...
...
@@ -37,7 +37,7 @@ class InformasiFasilitasTest(TestCase):
'phone_number'
:
000000000
,
'password'
:
"hahagotim"
}
lokasi_test_1
=
{
'id'
:
'1'
,
lokasi_test_1
=
{
'id'
:
1
,
'name'
:
'Ma Homie'
,
'latitude'
:
0.1
,
'longitude'
:
0.1
,
...
...
informasi_fasilitas/test_models.py
View file @
e659f0f0
...
...
@@ -3,7 +3,7 @@ from django.db.utils import IntegrityError
from
.test_base
import
InformasiFasilitasTest
from
.models
import
Lokasi
,
Fasilitas
,
Komentar
,
Likes
,
Dislikes
NOT_NULL_CONSTRAINT_FAILED_MESSAGE
=
'
null
'
NOT_NULL_CONSTRAINT_FAILED_MESSAGE
=
'
NOT NULL constraint failed
'
class
InformasiFasilitasModelTest
(
InformasiFasilitasTest
):
...
...
informasi_fasilitas/test_views_lokasi.py
View file @
e659f0f0
...
...
@@ -28,7 +28,6 @@ class LokasiRelatedViewTest(InformasiFasilitasViewTest):
response
=
Client
().
get
(
reverse
(
'lokasi-list'
))
content
=
json
.
loads
(
response
.
content
.
decode
(
'utf-8'
))
expected_first_entry
=
copy
.
deepcopy
(
self
.
lokasi_test_1
)
expected_first_entry
[
"id"
]
=
45
expected_first_entry
[
"image"
]
=
None
expected_json
=
[
expected_first_entry
]
self
.
assertEqual
(
content
,
expected_json
)
...
...
@@ -48,7 +47,7 @@ class LokasiRelatedViewTest(InformasiFasilitasViewTest):
content
=
json
.
loads
(
response
.
content
.
decode
(
'utf-8'
))
expected_json
=
copy
.
deepcopy
(
self
.
lokasi_test_1
)
expected_json
[
"image"
]
=
None
expected_json
[
"id"
]
=
35
#
expected_json["id"] = 35
self
.
assertEqual
(
content
,
expected_json
)
def
test_cannot_post_lokasi_details
(
self
):
...
...
@@ -68,7 +67,13 @@ class LokasiRelatedViewTest(InformasiFasilitasViewTest):
def
test_can_post_add_lokasi
(
self
):
client
=
self
.
client_user_token
()
Lokasi
.
objects
.
all
().
delete
()
response
=
client
.
post
(
reverse
(
'add-lokasi'
),
self
.
lokasi_test_1
)
response_json
=
json
.
loads
(
response
.
content
.
decode
(
"utf-8"
))
expected_json
=
copy
.
deepcopy
(
self
.
lokasi_test_1
)
expected_json
[
'id'
]
=
2
expected_json
[
'image'
]
=
None
self
.
assertEqual
(
response_json
,
expected_json
)
self
.
assertEqual
(
response
.
status_code
,
HTTPStatus
.
CREATED
)
def
test_post_add_lokasi_missing_key
(
self
):
...
...
@@ -87,17 +92,6 @@ class LokasiRelatedViewTest(InformasiFasilitasViewTest):
expected_json
=
{
"name"
:
[
"This field is required."
]}
self
.
assertEqual
(
response_json
,
expected_json
)
def
test_can_post_add_lokasi_json
(
self
):
client
=
self
.
client_user_token
()
response
=
client
.
post
(
reverse
(
'add-lokasi'
),
self
.
lokasi_test_1
)
response_json
=
json
.
loads
(
response
.
content
.
decode
(
"utf-8"
))
expected_json
=
copy
.
deepcopy
(
self
.
lokasi_test_1
)
expected_json
[
"id"
]
=
40
expected_json
[
"image"
]
=
None
self
.
assertEqual
(
response_json
,
expected_json
)
def
test_put_update_detail_lokasi_success
(
self
):
client
=
self
.
client_user_token
()
urls
=
reverse
(
'update-lokasi'
,
...
...
layanan_khusus/tests.py
View file @
e659f0f0
...
...
@@ -7,7 +7,7 @@ from django.urls import path, include, reverse
from
.models
import
Sekolah
,
Penyandang
,
Komunitas
from
.serializers
import
SekolahSerializer
,
KomunitasSerializer
NOT_NULL_CONSTRAINT_FAILED_MESSAGE
=
'
null
'
NOT_NULL_CONSTRAINT_FAILED_MESSAGE
=
'
NOT NULL constraint failed
'
ID
=
'id'
NAME
=
'name'
...
...
@@ -247,7 +247,6 @@ class LayananKhususViewsTest(TestCase):
MOCK_PENYANDANG
)
content
=
json
.
loads
(
response
.
content
.
decode
(
"utf-8"
))
expected_json
=
MOCK_PENYANDANG
expected_json
[
ID
]
=
3
self
.
assertEqual
(
content
,
expected_json
)
def
test_cannot_get_register_penyandang
(
self
):
...
...
@@ -285,12 +284,12 @@ class LayananKhususViewsTest(TestCase):
content
=
json
.
loads
(
response
.
content
.
decode
(
'utf-8'
))
expected_json
=
MOCK_KOMUNITAS
self
.
assertEqual
(
content
,
expected_json
)
def
test_cannot_post_detail_komunitas
(
self
):
response
=
Client
().
post
(
reverse
(
'detail-komunitas'
,
kwargs
=
{
'id_komunitas'
:
1
}))
self
.
assertEqual
(
response
.
status_code
,
HTTPStatus
.
METHOD_NOT_ALLOWED
)
def
test_get_details_komuniras_not_found
(
self
):
response
=
Client
().
get
(
reverse
(
'detail-komunitas'
,
kwargs
=
{
'id_komunitas'
:
1
}))
...
...
registrasi/tests.py
View file @
e659f0f0
...
...
@@ -17,4 +17,4 @@ class RegistrationTest(TestCase):
with
self
.
assertRaises
(
IntegrityError
)
as
error
:
obj
=
BisaGoUser
(
user
=
None
)
obj
.
save
()
self
.
assert
Fals
e
(
str
(
error
.
exception
).
startswith
(
'NOT NULL constraint failed'
))
self
.
assert
Tru
e
(
str
(
error
.
exception
).
startswith
(
'NOT NULL constraint failed'
))
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