@@ -1924,6 +1924,38 @@ def test_order_by_enrollments(self):
19241924 org = orgs [2 ]
19251925 self .assertEqual (org ['name' ], org3 .name )
19261926
1927+ def test_order_by_null (self ):
1928+ """Check whether it returns the organizations ordered by default (name)"""
1929+
1930+ indv1 = Individual .objects .create (mk = 'a9b403e150dd4af8953a52a4bb841051e4b705d9' )
1931+ indv2 = Individual .objects .create (mk = '0010a5211c03c46d340ada434b9f5b5072a8d491' )
1932+ indv3 = Individual .objects .create (mk = '86172d829d61adabde125d2442093213f745fbfd' )
1933+
1934+ org1 = Organization .add_root (name = 'Example' )
1935+ Enrollment .objects .create (individual = indv1 , group = org1 )
1936+ Enrollment .objects .create (individual = indv2 , group = org1 )
1937+ Enrollment .objects .create (individual = indv3 , group = org1 )
1938+
1939+ org2 = Organization .add_root (name = 'Bitergia' )
1940+ Enrollment .objects .create (individual = indv1 , group = org2 )
1941+ Enrollment .objects .create (individual = indv2 , group = org2 )
1942+
1943+ org3 = Organization .add_root (name = 'LibreSoft' )
1944+
1945+ # Test default order by null
1946+ client = graphene .test .Client (schema )
1947+ executed = client .execute ("""{ organizations (orderBy: null){ entities { name } } }""" ,
1948+ context_value = self .context_value )
1949+
1950+ orgs = executed ['data' ]['organizations' ]['entities' ]
1951+
1952+ org = orgs [0 ]
1953+ self .assertEqual (org ['name' ], org2 .name )
1954+ org = orgs [1 ]
1955+ self .assertEqual (org ['name' ], org1 .name )
1956+ org = orgs [2 ]
1957+ self .assertEqual (org ['name' ], org3 .name )
1958+
19271959 def test_pagination (self ):
19281960 """Check whether it returns the organizations searched when using pagination"""
19291961
@@ -4295,6 +4327,29 @@ def test_order_by_identities_count(self):
42954327 indv = individuals [2 ]
42964328 self .assertEqual (indv ['mk' ], indv1 .mk )
42974329
4330+ def test_order_by_null (self ):
4331+ """Check whether it returns the indifiduals sorted by default (mk) when ordering by null"""
4332+
4333+ indv1 = Individual .objects .create (mk = 'aaaa03e150dd4af8953a52a4bb841051e4b705d9' )
4334+ indv2 = Individual .objects .create (mk = 'cccc4b709e5446d250b4fde0e34b78a2b4fde0e3' )
4335+ indv3 = Individual .objects .create (mk = 'bbbbde0e34b78a185c4b709e5442d045451c' )
4336+ Profile .objects .create (name = 'AA' , individual = indv1 )
4337+ Profile .objects .create (name = 'ZZ' , individual = indv2 )
4338+ Profile .objects .create (name = 'MM' , individual = indv3 )
4339+
4340+ client = graphene .test .Client (schema )
4341+ executed = client .execute ("""{ individuals(orderBy: null) { entities { mk } } }""" ,
4342+ context_value = self .context_value )
4343+
4344+ individuals = executed ['data' ]['individuals' ]['entities' ]
4345+
4346+ indv = individuals [0 ]
4347+ self .assertEqual (indv ['mk' ], indv1 .mk )
4348+ indv = individuals [1 ]
4349+ self .assertEqual (indv ['mk' ], indv3 .mk )
4350+ indv = individuals [2 ]
4351+ self .assertEqual (indv ['mk' ], indv2 .mk )
4352+
42984353 def test_pagination (self ):
42994354 """Check whether it returns the individuals searched when using pagination"""
43004355
0 commit comments