Coverage for tests / unit / utils / test_parser_utils.py: 0%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-20 10:09 -0400

1from graphqler.utils.parser_utils import get_base_oftype, get_output_type 

2 

3 

4def test_get_base_oftype(): 

5 # Test case 1 

6 oftype = {"kind": "NON_NULL", "name": None, "ofType": {"kind": "LIST", "name": None, "ofType": {"kind": "SCALAR", "name": "String", "ofType": None}}} 

7 expected_output = {"kind": "SCALAR", "name": "String", "ofType": None} 

8 assert get_base_oftype(oftype) == expected_output 

9 

10 # Test case 2 

11 oftype = {"kind": "NON_NULL", "name": None, "ofType": {"kind": "SCALAR", "name": "Int", "ofType": None}} 

12 expected_output = {"kind": "SCALAR", "name": "Int", "ofType": None} 

13 assert get_base_oftype(oftype) == expected_output 

14 

15 

16def test_get_output_type(): 

17 # Test case 1 

18 payload_name = "createUser" 

19 mutations = { 

20 "createUser": {"output": {"kind": "OBJECT", "name": "CreateUserPayload", "ofType": None, "type": "User"}}, 

21 "updateUser": {"output": {"kind": "OBJECT", "name": "User", "ofType": None, "type": "User"}}, 

22 } 

23 expected_output = "User" 

24 assert get_output_type(payload_name, mutations) == expected_output