File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
backend/family_tree/student Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1
1
from django .test import TestCase
2
+ import json
3
+ from graphene_django .utils .testing import GraphQLTestCase
4
+ from student .models import Student
5
+ from mixer .backend .django import mixer
2
6
3
- # Create your tests here.
7
+ class testCasesForStudents (GraphQLTestCase ):
8
+ GRAPHQL_URL = 'http://localhost/graphql'
9
+ def setUp (self ):
10
+ super ().setUp ()
11
+ self .student1 = mixer .blend (Student , name = 'student1' )
12
+ self .student2 = mixer .blend (Student , name = 'student2' )
13
+ def test_student_query (self ):
14
+ response = self .query ('''
15
+ query {
16
+ students {
17
+ id
18
+ name
19
+ }
20
+ }
21
+ ''' )
22
+ content = json .loads (response .content )
23
+ self .assertResponseNoErrors (response )
24
+ self .assertDictEqual (content ['data' ]['students' ][0 ], {'id' : str (self .student1 .id ), 'name' : self .student1 .name })
25
+ self .assertDictEqual (content ['data' ]['students' ][1 ], {'id' : str (self .student2 .id ), 'name' : self .student2 .name })
You can’t perform that action at this time.
0 commit comments