Beispiel #1
0
def test_invalid_options():
    with pytest.raises(ParseError) as type_err:
        export(Node([Field('kott', options={'clauber': UNKNOWN})]))
    type_err.match('has unexpected type')

    with pytest.raises(ParseError) as item_type_err:
        export(Node([Field('puerco', options={'bayat': [1, UNKNOWN, 3]})]))
    item_type_err.match('has unexpected type')
Beispiel #2
0
def test_node():
    node = query_pb2.Node()
    node.items.add().field.name = 'aimer'

    query = Node([Field('aimer')])

    assert export(query) == node
Beispiel #3
0
def test_field_options():
    node = query_pb2.Node()
    field = node.items.add().field
    field.name = 'cody'
    field.options['kink'] = 1234
    field.options['cithara'] = 'slasher'

    query = Node([Field('cody', options={'kink': 1234, 'cithara': 'slasher'})])

    assert export(query) == node
Beispiel #4
0
def test_query_reading():
    from hiku.builder import build, Q
    from hiku.export.protobuf import export

    binary_message = export(build([Q.characters[Q.name]])).SerializeToString()

    from hiku.readers.protobuf import read

    query = read(binary_message)

    result = hiku_engine.execute(GRAPH, query)

    assert all(c['name'] for c in result['characters'])
Beispiel #5
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
Beispiel #6
0
def test_query_export():
    from hiku.protobuf import query_pb2

    node = query_pb2.Node()

    link = node.items.add().link
    link.name = 'characters'

    field = link.node.items.add().field
    field.name = 'name'

    from hiku.builder import build, Q
    from hiku.export.protobuf import export

    query = build([
        Q.characters[Q.name, ],
    ])

    message = export(query)
    assert message == node

    binary_message = message.SerializeToString()
    assert binary_message