Fakultas Ilmu Komputer UI

Commit 549622a5 authored by Ilma Ainur Rohma's avatar Ilma Ainur Rohma
Browse files

[RED] add test for read detail and delete

parent d8009e5f
......@@ -32,4 +32,4 @@ class MustahikMutation(DjangoModelFormMutation):
mustahik = graphene.Field(MustahikType)
class Meta:
form_class = MustahikForm
form_class = MustahikForm
\ No newline at end of file
......@@ -15,3 +15,4 @@ class MustahikQuery(graphene.ObjectType):
return Mustahik.objects.filter(filter)
return Mustahik.objects.all()
......@@ -233,3 +233,55 @@ class MustahikGraphQLTestCase(GraphQLTestCase):
content = json.loads(response.content)
self.assertEqual(len(content['data']['mustahiks']), 0)
def test_mustahik_mutation_can_delete_mustahik(self):
count = Mustahik.objects.count()
response = self.query(
'''
mutation{
deleteMustahik(id: 3) {
mustahik {
id
name
}
}
}
''',
)
self.assertResponseNoErrors(response)
content = json.loads(response.content)
self.assertIsNone(content['data']['deleteMustahik'])
self.assertEquals(Mustahik.objects.count(), count-1)
def test_mustahik_query_can_read_detail_mustahik(self):
mustahik = Mustahik.objects.get(no_ktp='31751234567890')
mustahik_id = mustahik.pk
response = self.query(
'''
query detailMustahikQuery($id:ID){
mustahik(id:$id){
id
name
noKtp
phone
address
province
regency
rt
rw
birthdate
status
familySize
description
}
}
''',
op_name='detailMustahikQuery',
variables={'id':mustahik_id}
)
content = json.loads(response.content)
self.assertEqual(len(content['data']), 1)
self.assertEqual(content['data']['mustahik']['name'], 'mustahik')
self.assertEqual(content['data']['mustahik']['noKtp'], '31751234567890')
self.assertEqual(content['data']['mustahik']['address'], 'Jalan raya depok')
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment