1
+ from django .http import response
1
2
from django .test import TestCase
2
3
from graphene_django .utils .testing import GraphQLTestCase
3
4
import json
@@ -10,10 +11,10 @@ class StudentTestCases(GraphQLTestCase):
10
11
11
12
def setUp (self ):
12
13
super ().setUp ()
13
- self .student1 = mixer .blend (Student , name = 'student1' , roll_no = '1' , parentId = None )
14
- self .student2 = mixer .blend (Student , name = 'student2' , roll_no = '2' , parentId = '1' )
15
- self .student3 = mixer .blend (Student , name = 'student3' , roll_no = '3' , parentId = '1' )
16
- self .student4 = mixer .blend (Student , name = 'student4' , roll_no = '4' , parentId = '1' )
14
+ self .student1 = mixer .blend (Student , name = 'student1' , roll_no = '1' , parentId = None , year = 2019 )
15
+ self .student2 = mixer .blend (Student , name = 'student2' , roll_no = '2' , parentId = '1' , year = 2020 )
16
+ self .student3 = mixer .blend (Student , name = 'student3' , roll_no = '3' , parentId = '1' , year = 2020 )
17
+ self .student4 = mixer .blend (Student , name = 'student4' , roll_no = '4' , parentId = '1' , year = 2020 )
17
18
self .student5 = mixer .blend (Student , name = 'student5' , roll_no = '5' , parentId = '2' )
18
19
self .student6 = mixer .blend (Student , name = 'student6' , roll_no = '6' , parentId = '5' )
19
20
self .student7 = mixer .blend (Student , name = 'student7' , roll_no = '7' , parentId = '6' )
@@ -64,6 +65,24 @@ def test_student_sibling(self):
64
65
self .assertDictEqual (content ['data' ]['studentSibling' ][0 ], {'id' : str (self .student3 .id ), 'name' : self .student3 .name })
65
66
self .assertDictEqual (content ['data' ]['studentSibling' ][1 ], {'id' : str (self .student4 .id ), 'name' : self .student4 .name })
66
67
68
+ def test_student_batch (self ):
69
+ response = self .query ('''
70
+ query {
71
+ studentBatch(roll: "2") {
72
+ id
73
+ name
74
+ }
75
+ }
76
+ ''' )
77
+ content = json .loads (response .content )
78
+ self .assertResponseNoErrors (response )
79
+ self .assertDictEqual (content ['data' ]['studentBatch' ][0 ][0 ], {'id' : str (self .student2 .id ), 'name' : self .student2 .name })
80
+ self .assertDictEqual (content ['data' ]['studentBatch' ][0 ][1 ], {'id' : str (self .student1 .id ), 'name' : self .student1 .name })
81
+ self .assertDictEqual (content ['data' ]['studentBatch' ][1 ][0 ], {'id' : str (self .student3 .id ), 'name' : self .student3 .name })
82
+ self .assertDictEqual (content ['data' ]['studentBatch' ][1 ][1 ], {'id' : str (self .student1 .id ), 'name' : self .student1 .name })
83
+ self .assertDictEqual (content ['data' ]['studentBatch' ][2 ][0 ], {'id' : str (self .student4 .id ), 'name' : self .student4 .name })
84
+ self .assertDictEqual (content ['data' ]['studentBatch' ][1 ][1 ], {'id' : str (self .student1 .id ), 'name' : self .student1 .name })
85
+
67
86
def test_student_path (self ):
68
87
response = self .query ('''
69
88
query {
@@ -72,7 +91,7 @@ def test_student_path(self):
72
91
name
73
92
}
74
93
}
75
- ''' )
94
+ ''' )
76
95
content = json .loads (response .content )
77
96
self .assertResponseNoErrors (response )
78
97
self .assertDictEqual (content ['data' ]['studentPath' ][6 ], {'id' : str (self .student1 .id ), 'name' : self .student1 .name })
0 commit comments