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
Sistem Informasi Zakat
Sizakat 5.0 (Refactoring)
Sizakat Backend
Commits
9669fd1a
Commit
9669fd1a
authored
Aug 05, 2020
by
addffa
Browse files
[RED] membuat test model transaction
parent
8f6ca8f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
sizakat/transaction/tests.py
View file @
9669fd1a
from
django.test
import
TestCase
# Create your tests here.
from
.models
import
Muzakki
,
Transaction
,
ZakatType
,
ZakatTransaction
class
TransactionModelTestCase
(
TestCase
):
def
setUp
(
self
):
muzakki
=
Muzakki
.
objects
.
create
(
no_ktp
=
'1234567890'
,
name
=
'tester'
,
phone
=
'081234567890'
)
zakat_type
=
ZakatType
.
objects
.
create
(
name
=
'Zakat Fitrah'
,
item_type
=
ZakatType
.
ItemType
.
MONEY
)
transaction
=
Transaction
.
objects
.
create
(
payment_type
=
Transaction
.
PaymentType
.
CASH
,
)
ZakatTransaction
.
objects
.
create
(
value
=
50000
,
zakat_type
=
zakat_type
,
muzakki
=
muzakki
,
transaction
=
transaction
)
def
test_muzakki_creation
(
self
):
muzakki
=
Muzakki
.
objects
.
get
(
no_ktp
=
'1234567890'
)
self
.
assertTrue
(
isinstance
(
muzakki
,
Muzakki
))
def
test_zakat_type_creation
(
self
):
zakat_type
=
ZakatType
.
objects
.
get
(
name
=
'Zakat Fitrah'
)
self
.
assertTrue
(
isinstance
(
zakat_type
,
ZakatType
))
def
test_transaction_creation
(
self
):
transactions
=
Transaction
.
objects
.
all
()
transaction
=
Transaction
.
objects
.
get
(
pk
=
transactions
[
0
].
pk
)
self
.
assertTrue
(
isinstance
(
transaction
,
Transaction
))
def
test_zakat_transaction_creation
(
self
):
zakat_transactions
=
ZakatTransaction
.
objects
.
all
()
zakat_transaction
=
ZakatTransaction
.
objects
.
get
(
pk
=
zakat_transactions
[
0
].
pk
)
self
.
assertTrue
(
isinstance
(
zakat_transaction
,
ZakatTransaction
))
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