Beispiel #1
0
def write_quad(subject, predicate, object):
    client = CayleyClient()
    g = CayleyWrite()
    g.append(subject, predicate, object)
    status_code, result = client.write(g)
    if status_code == 200:
        return True
    return False
Beispiel #2
0
def get_direct_relation(name):
    client = CayleyClient()
    g = CayleyGraphObject()
    query_data = g.V(name) \
        .Tag('subject') \
        .Out('null', 'predicate') \
        .Tag('object') \
        .All()
    status_code, result = client.query(query_data)
    if status_code == 200 and result['result'] is not None:
        return True, result
    return False, None
Beispiel #3
0
    def test_query(self):
        client = CayleyClient()
        g = CayleyGraphObject()
        query = g.V() \
            .Tag('subject') \
            .Out('null', 'predicate') \
            .Tag('object') \
            .All()
        status, result = client.query(query)

        print result
        self.assertEqual(status, 200)
        self.assertTrue(len(result) > 0)