Skip to content

Commit 0048456

Browse files
creates test cases for fetch batch resolver
1 parent 1eeed7a commit 0048456

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

backend/family_tree/student/tests.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.http import response
12
from django.test import TestCase
23
import json
34
from graphene_django.utils.testing import GraphQLTestCase
@@ -8,10 +9,10 @@ class testCasesForStudents(GraphQLTestCase):
89
GRAPHQL_URL = 'http://localhost/graphql'
910
def setUp(self):
1011
super().setUp()
11-
self.student1 = mixer.blend(Student, name='student1', roll_no='1', parentId='root')
12-
self.student2 = mixer.blend(Student, name='student2', roll_no='2', parentId='1')
13-
self.student3 = mixer.blend(Student, name='student3', roll_no='3', parentId='1')
14-
self.student4 = mixer.blend(Student, name='student4', roll_no='4', parentId='1')
12+
self.student1 = mixer.blend(Student, name='student1', roll_no='1', parentId='root', year=2019)
13+
self.student2 = mixer.blend(Student, name='student2', roll_no='2', parentId='1', year=2020)
14+
self.student3 = mixer.blend(Student, name='student3', roll_no='3', parentId='1', year=2020)
15+
self.student4 = mixer.blend(Student, name='student4', roll_no='4', parentId='1', year=2020)
1516
def test_student_query(self):
1617
response = self.query('''
1718
query {
@@ -37,4 +38,24 @@ def test_student_sibling(self):
3738
content= json.loads(response.content)
3839
self.assertResponseNoErrors(response)
3940
self.assertDictEqual(content['data']['studentSibling'][0], {'id': str(self.student3.id), 'name': self.student3.name})
40-
self.assertDictEqual(content['data']['studentSibling'][1], {'id': str(self.student4.id), 'name': self.student4.name})
41+
self.assertDictEqual(content['data']['studentSibling'][1], {'id': str(self.student4.id), 'name': self.student4.name})
42+
43+
def test_student_batch(self):
44+
response= self.query('''
45+
query {
46+
studentBatch(roll: "2") {
47+
id
48+
name
49+
}
50+
}
51+
''')
52+
content= json.loads(response.content)
53+
self.assertResponseNoErrors(response)
54+
self.assertDictEqual(content['data']['studentBatch'][0][0], {'id': str(self.student2.id), 'name': self.student2.name})
55+
self.assertDictEqual(content['data']['studentBatch'][0][1], {'id': str(self.student1.id), 'name': self.student1.name})
56+
self.assertDictEqual(content['data']['studentBatch'][1][0], {'id': str(self.student3.id), 'name': self.student3.name})
57+
self.assertDictEqual(content['data']['studentBatch'][1][1], {'id': str(self.student1.id), 'name': self.student1.name})
58+
self.assertDictEqual(content['data']['studentBatch'][2][0], {'id': str(self.student4.id), 'name': self.student4.name})
59+
self.assertDictEqual(content['data']['studentBatch'][1][1], {'id': str(self.student1.id), 'name': self.student1.name})
60+
61+

0 commit comments

Comments
 (0)