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
2020
PPL-C
DTB-Layanan Fasilitas Publik Penyandang Disabilitas
PoiPoLeGan-PPLapanganTembak-DTB Layanan Fasilitas Publik Penyandang Disabilitas-BE
Commits
8f9dfd50
Commit
8f9dfd50
authored
Apr 17, 2020
by
Bimo Iman Smartadi
Browse files
[REFACTOR] Changed error message to a variable
parent
6968ab82
Changes
1
Show whitespace changes
Inline
Side-by-side
informasi_fasilitas/tests.py
View file @
8f9dfd50
from
django.test
import
TestCase
from
django.db.utils
import
IntegrityError
from
.models
import
Lokasi
,
Fasilitas
,
Komentar
,
KURSI_RODA
,
RUNNING_TEXT
#
from registrasi.models import User
from
registrasi.models
import
BisaGo
User
from
django.contrib.auth.models
import
User
import
tempfile
# Create your tests here.
class
Informasi_Fasilitas_Test
(
TestCase
):
class
InformasiFasilitasTest
(
TestCase
):
not_null_constraint_failed
=
'NOT NULL constraint failed'
def
test_models_lokasi_not_created
(
self
):
with
self
.
assertRaises
(
IntegrityError
)
as
cm
:
obj
=
Lokasi
(
name
=
None
)
obj
.
save
();
self
.
assertTrue
(
str
(
cm
.
exception
).
startswith
(
'NOT NULL
constraint
failed
'
))
self
.
assertTrue
(
str
(
cm
.
exception
).
startswith
(
not_null_
constraint
_
failed
))
def
test_models_create_new_lokasi
(
self
):
image
=
tempfile
.
NamedTemporaryFile
(
suffix
=
".jpg"
).
name
...
...
@@ -31,7 +32,7 @@ class Informasi_Fasilitas_Test(TestCase):
with
self
.
assertRaises
(
IntegrityError
)
as
cm
:
obj
=
Fasilitas
(
lokasi
=
None
)
obj
.
save
();
self
.
assertTrue
(
str
(
cm
.
exception
).
startswith
(
'NOT NULL
constraint
failed
'
))
self
.
assertTrue
(
str
(
cm
.
exception
).
startswith
(
not_null_
constraint
_
failed
))
def
test_models_create_new_fasilitas
(
self
):
image
=
tempfile
.
NamedTemporaryFile
(
suffix
=
".jpg"
).
name
...
...
@@ -68,7 +69,7 @@ class Informasi_Fasilitas_Test(TestCase):
with
self
.
assertRaises
(
IntegrityError
)
as
cm
:
obj
=
Komentar
(
fasilitas
=
None
)
obj
.
save
();
self
.
assertTrue
(
str
(
cm
.
exception
).
startswith
(
'NOT NULL
constraint
failed
'
))
self
.
assertTrue
(
str
(
cm
.
exception
).
startswith
(
not_null_
constraint
_
failed
))
def
test_models_create_new_komentar
(
self
):
image
=
tempfile
.
NamedTemporaryFile
(
suffix
=
".jpg"
).
name
...
...
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