def test_link_options(): node = query_pb2.Node() link = node.items.add().link link.name = 'pommee' link.options['takest'] = 3456 link.options['decoy'] = 'nyroca' field = link.node.items.add().field field.name = 'fugazi' query = Node([ Link('pommee', Node([Field('fugazi')]), options={ 'takest': 3456, 'decoy': 'nyroca' }) ]) assert export(query) == node
def test_variables_in_fragment(): check_read( """ query Jester($pushy: Int, $popedom: Int!, $tookies: Int! = 234) { ...Pujari } fragment Pujari on Ashlee { fibbery(baps: $pushy, bankit: $popedom, riuer: $tookies) } """, Node([ Field('fibbery', options={ 'baps': None, 'bankit': 123, 'riuer': 234 }) ]), {'popedom': 123}, )
def testTupleWithLinks(self): self.assertRequires( foo(S.x1, S.y1), Edge([Link('x1', Edge([Field('a'), Field('c')])), Link('y1', Edge([Field('d'), Field('f')]))]), ) self.assertRequires( each(S.item, S.xs, foo(S.item, S.y1)), Edge([Link('xs', Edge([Field('a'), Field('c')])), Link('y1', Edge([Field('d'), Field('f')]))]), ) self.assertRequires( each(S.item, S.ys, foo(S.x1, S.item)), Edge([Link('x1', Edge([Field('a'), Field('c')])), Link('ys', Edge([Field('d'), Field('f')]))]), ) self.assertRequires( each(S.item, S.ys, foo(S.item.x1, S.item)), Edge([Link('ys', Edge([Field('d'), Field('f'), Link('x1', Edge([Field('a'), Field('c')]))]))]), )
def test_ref_add_req(): check_req(NamedRef(None, 'comped', ROOT_TYPES['comped']), Node([Link('comped', Node([Field('clacks'), Field('panicle')]))]), add_req=Node([Field('clacks'), Field('panicle')]))
def testTupleWithEdges(self): self.assertRequires( foo(S.x, S.y), Edge([Link('x', Edge([Field('a'), Field('c')])), Link('y', Edge([Field('d'), Field('f')]))]), )
def test_query_node_field(): check_query( S.weigh.clacks, Node([Link('weigh', Node([Field('clacks')]))]), )
def enter_SelectionSet(self, node, key, parent, path, ancestors): for field in node.selections: self._stack[-1].fields[field.name.value] = Field(field.name.value)
def test(): q1 = Node([Field('a1'), Field('a2'), Link('b', Node([Field('b1'), Field('b2')]))]) q2 = Node([Field('a2'), Field('a3'), Link('b', Node([Field('b2'), Field('b3')]))]) query = merge([q1, q2]) expected = Node([Field('a1'), Field('a2'), Field('a3'), Link('b', Node([Field('b1'), Field('b2'), Field('b3')]))]) with reqs_eq_patcher(): assert query == expected
def test_complex_field(): check_read( '{ saale { slighty } }', Node([Link('saale', Node([Field('slighty')]))]), )
def test_ref_root_field(): check_req(NamedRef(None, 'sailed', ROOT_TYPES['sailed']), Node([Field('sailed')]))
def test(self): with reqs_eq_patcher(): self.assertEqual( merge([ Edge([Field('a1'), Field('a2'), Link('b', Edge([Field('b1'), Field('b2')]))]), Edge([Field('a2'), Field('a3'), Link('b', Edge([Field('b2'), Field('b3')]))]), ]), Edge([Field('a1'), Field('a2'), Field('a3'), Link('b', Edge([Field('b1'), Field('b2'), Field('b3')]))]), )
def test_query_list_scalar(): check_query(S.dilo, Node([Field('dilo')]))
def test_query_if_some(): check_query( if_some([S.x, S.civics], S.x.clacks, 'false'), Node([Link('civics', Node([Field('clacks')]))]), )
def test_query_each_root_node_link_field(): check_query( each(S.item, S.malatya.wandy, S.item.clacks), Node([Link('malatya', Node([Link('wandy', Node([Field('clacks')]))]))]), )
def test_query_each_node_field(): check_query( each(S.item, S.comped, S.item.clacks), Node([Link('comped', Node([Field('clacks')]))]), )
def test_query_root_node_link_field(): check_query( S.malatya.teling.clacks, Node([Link('malatya', Node([Link('teling', Node([Field('clacks')]))]))]), )
def testField(self): self.assertReq(NamedRef(None, 'f', Env.f), Edge([Field('f')]))
def testField(self): self.assertRequires(S.f, Edge([Field('f')]))
def testAddReq(self): self.assertReq(NamedRef(None, 'xs', Env.xs), Edge([Link('xs', Edge([Field('a'), Field('c')]))]), add_req=Edge([Field('a'), Field('c')]))
def test_read_operation_query(): op = read_operation('query { pong }') assert op.type is OperationType.QUERY assert op.query == Node([Field('pong')])
def test_field_alias(): check_read( '{ a: b }', Node([Field('b', alias='a')]), )
def test_read_operation_subscription(): op = read_operation('subscription { ping }') assert op.type is OperationType.SUBSCRIPTION assert op.query == Node([Field('ping')])
def testLinkField(self): self.assertRequires( S.x1.a, Edge([Link('x1', Edge([Field('a')]))]), )
def test_query_root_field(): check_query(S.sailed, Node([Field('sailed')]))
def test_read_operation_mutation(): op = read_operation('mutation { ping }') assert op.type is OperationType.MUTATION assert op.query == Node([Field('ping')], ordered=True)
def testEdgeLinkField(self): self.assertRequires( S.y.x1.b, Edge([Link('y', Edge([Link('x1', Edge([Field('b')]))]))]), )
def test_field(): check_read( '{ vaward }', Node([Field('vaward')]), )
def testEachLinkField(self): self.assertRequires( each(S.item, S.xs, S.item.a), Edge([Link('xs', Edge([Field('a')]))]), )
def test_node_field(): node = t.Node() item = node.items.add() item.field.name = 'tratan' check_read(node, Node([Field('tratan')]))
def testEdgeEachLinkField(self): self.assertRequires( each(S.item, S.y.xs, S.item.b), Edge([Link('y', Edge([Link('xs', Edge([Field('b')]))]))]), )