Skip to content

Commit

Permalink
Add test and logging for #16 and #20
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitastupin committed Sep 3, 2021
1 parent 871605d commit 2d0e08c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clairvoyance/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,12 @@ def probe_typeref(

for error in errors:
typeref = get_typeref(error["message"], context)
logging.debug(f"get_typeref('{error['message']}', '{context}') -> {typeref}")
if typeref:
return typeref

if not typeref:
raise Exception(f"Unable to get TypeRef for {documents}")
raise Exception(f"Unable to get TypeRef for {documents} in context {context}")

return None

Expand Down
17 changes: 17 additions & 0 deletions tests/oracle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,23 @@ def test_skip_error_message(self):
self.assertEqual(want, got)
self.assertCountEqual(["WARNING:root:Dummy warning"], cm.output)

def test_issue_16(self):
want = graphql.TypeRef(
name="ID",
kind="SCALAR",
is_list=False,
non_null_item=False,
non_null=True,
)
got = oracle.get_typeref(
'Field "node" argument "id" of type "ID!" is required but not provided.', "InputValue"
)
self.assertEqual(got.name, want.name)
self.assertEqual(got.kind, want.kind)
self.assertEqual(got.is_list, want.is_list)
self.assertEqual(got.non_null_item, want.non_null_item)
self.assertEqual(got.non_null, want.non_null)


class TestTypeRef(unittest.TestCase):
def test_to_json(self):
Expand Down

0 comments on commit 2d0e08c

Please sign in to comment.