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
90b2dfea
Commit
90b2dfea
authored
Aug 06, 2020
by
addffa
Browse files
[RED] membuat test query transaction
parent
592fd63a
Changes
1
Hide whitespace changes
Inline
Side-by-side
sizakat/transaction/tests.py
View file @
90b2dfea
import
json
from
django.test
import
TestCase
from
graphene_django.utils.testing
import
GraphQLTestCase
from
sizakat.schema
import
schema
from
.models
import
Muzakki
,
Transaction
,
ZakatType
,
ZakatTransaction
...
...
@@ -43,3 +47,64 @@ class TransactionModelTestCase(TestCase):
pk
=
zakat_transactions
[
0
].
pk
)
self
.
assertTrue
(
isinstance
(
zakat_transaction
,
ZakatTransaction
))
class
TransactionGraphQLTest
(
GraphQLTestCase
):
GRAPHQL_SCHEMA
=
schema
def
setUp
(
self
):
self
.
muzakki
=
Muzakki
.
objects
.
create
(
no_ktp
=
'1234567890'
,
name
=
'tester'
,
phone
=
'081234567890'
)
self
.
zakat_type
=
ZakatType
.
objects
.
create
(
name
=
'Zakat Fitrah'
,
item_type
=
ZakatType
.
ItemType
.
MONEY
)
self
.
transaction
=
Transaction
.
objects
.
create
(
payment_type
=
Transaction
.
PaymentType
.
CASH
,
)
self
.
zakat_transaction
=
ZakatTransaction
.
objects
.
create
(
value
=
50000
,
zakat_type
=
self
.
zakat_type
,
muzakki
=
self
.
muzakki
,
transaction
=
self
.
transaction
)
def
test_zakat_type_query_return_list_of_zakat_type
(
self
):
response
=
self
.
query
(
'''
{
zakatTypes {
id
name
itemType
}
}
'''
)
self
.
assertResponseNoErrors
(
response
)
content
=
json
.
loads
(
response
.
content
)[
'data'
][
'zakatTypes'
]
self
.
assertTrue
(
isinstance
(
content
,
list
))
def
test_transactions_query_return_list_of_transaction
(
self
):
response
=
self
.
query
(
'{ transactions { id } }'
)
self
.
assertResponseNoErrors
(
response
)
content
=
json
.
loads
(
response
.
content
)[
'data'
][
'transactions'
]
self
.
assertTrue
(
isinstance
(
content
,
list
))
def
test_transaction_query_with_id_return_specific_transaction
(
self
):
response
=
self
.
query
(
'''
{
transaction(transactionId: %d) {
id
paymentType
}
}
'''
%
(
self
.
transaction
.
pk
)
)
transaction
=
json
.
loads
(
response
.
content
)[
'data'
][
'transaction'
]
self
.
assertEqual
(
str
(
transaction
[
'id'
]),
str
(
self
.
transaction
.
pk
))
self
.
assertEqual
(
transaction
[
'paymentType'
],
self
.
transaction
.
payment_type
)
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