Пример #1
0
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
Пример #2
0
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},
    )
Пример #3
0
 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')]))]))]),
     )
Пример #4
0
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')]))
Пример #5
0
 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')]))]),
     )
Пример #6
0
def test_query_node_field():
    check_query(
        S.weigh.clacks,
        Node([Link('weigh', Node([Field('clacks')]))]),
    )
Пример #7
0
 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)
Пример #8
0
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
Пример #9
0
def test_complex_field():
    check_read(
        '{ saale { slighty } }',
        Node([Link('saale', Node([Field('slighty')]))]),
    )
Пример #10
0
def test_ref_root_field():
    check_req(NamedRef(None, 'sailed', ROOT_TYPES['sailed']),
              Node([Field('sailed')]))
Пример #11
0
 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')]))]),
         )
Пример #12
0
def test_query_list_scalar():
    check_query(S.dilo, Node([Field('dilo')]))
Пример #13
0
def test_query_if_some():
    check_query(
        if_some([S.x, S.civics], S.x.clacks, 'false'),
        Node([Link('civics', Node([Field('clacks')]))]),
    )
Пример #14
0
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')]))]))]),
    )
Пример #15
0
def test_query_each_node_field():
    check_query(
        each(S.item, S.comped, S.item.clacks),
        Node([Link('comped', Node([Field('clacks')]))]),
    )
Пример #16
0
def test_query_root_node_link_field():
    check_query(
        S.malatya.teling.clacks,
        Node([Link('malatya',
                   Node([Link('teling', Node([Field('clacks')]))]))]),
    )
Пример #17
0
 def testField(self):
     self.assertReq(NamedRef(None, 'f', Env.f),
                    Edge([Field('f')]))
Пример #18
0
 def testField(self):
     self.assertRequires(S.f, Edge([Field('f')]))
Пример #19
0
 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')]))
Пример #20
0
def test_read_operation_query():
    op = read_operation('query { pong }')
    assert op.type is OperationType.QUERY
    assert op.query == Node([Field('pong')])
Пример #21
0
def test_field_alias():
    check_read(
        '{ a: b }',
        Node([Field('b', alias='a')]),
    )
Пример #22
0
def test_read_operation_subscription():
    op = read_operation('subscription { ping }')
    assert op.type is OperationType.SUBSCRIPTION
    assert op.query == Node([Field('ping')])
Пример #23
0
 def testLinkField(self):
     self.assertRequires(
         S.x1.a,
         Edge([Link('x1', Edge([Field('a')]))]),
     )
Пример #24
0
def test_query_root_field():
    check_query(S.sailed, Node([Field('sailed')]))
Пример #25
0
def test_read_operation_mutation():
    op = read_operation('mutation { ping }')
    assert op.type is OperationType.MUTATION
    assert op.query == Node([Field('ping')], ordered=True)
Пример #26
0
 def testEdgeLinkField(self):
     self.assertRequires(
         S.y.x1.b,
         Edge([Link('y', Edge([Link('x1', Edge([Field('b')]))]))]),
     )
Пример #27
0
def test_field():
    check_read(
        '{ vaward }',
        Node([Field('vaward')]),
    )
Пример #28
0
 def testEachLinkField(self):
     self.assertRequires(
         each(S.item, S.xs, S.item.a),
         Edge([Link('xs', Edge([Field('a')]))]),
     )
Пример #29
0
def test_node_field():
    node = t.Node()
    item = node.items.add()
    item.field.name = 'tratan'
    check_read(node, Node([Field('tratan')]))
Пример #30
0
 def testEdgeEachLinkField(self):
     self.assertRequires(
         each(S.item, S.y.xs, S.item.b),
         Edge([Link('y', Edge([Link('xs', Edge([Field('b')]))]))]),
     )