コード例 #1
0
 def make_fixtures(self):
     self.app.post('/api/1/networks',
                 headers=AUTHZ_HEADER,
                 data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION,
                   h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY,
                   h.TEST_ENTITY_SCHEMA)
     res = self.app.post('/api/1/net/entities', 
                 headers=AUTHZ_HEADER,
                 data=ENTITY1_FIXTURE, 
                 follow_redirects=True)
     body = json.loads(res.data)
     self.source_id = body['id']
     res = self.app.post('/api/1/net/entities',
                 headers=AUTHZ_HEADER,
                 data=ENTITY2_FIXTURE, 
                 follow_redirects=True)
     body = json.loads(res.data)
     self.target_id = body['id']
     RELATION_FIXTURE['source'] = self.source_id
     RELATION_FIXTURE['target'] = self.target_id
     res = self.app.post('/api/1/net/relations', 
                 headers=AUTHZ_HEADER,
                 data=RELATION_FIXTURE, 
                 follow_redirects=True)
     print res.data
     body = json.loads(res.data)
     self.id = body['id']
コード例 #2
0
 def make_fixtures(self):
     self.app.post('/api/1/networks',
                   headers=AUTHZ_HEADER,
                   data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION, h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY, h.TEST_ENTITY_SCHEMA)
     res = self.app.post('/api/1/net/entities',
                         headers=AUTHZ_HEADER,
                         data=ENTITY1_FIXTURE,
                         follow_redirects=True)
     body = json.loads(res.data)
     self.source_id = body['id']
     res = self.app.post('/api/1/net/entities',
                         headers=AUTHZ_HEADER,
                         data=ENTITY2_FIXTURE,
                         follow_redirects=True)
     body = json.loads(res.data)
     self.target_id = body['id']
     RELATION_FIXTURE['source'] = self.source_id
     RELATION_FIXTURE['target'] = self.target_id
     res = self.app.post('/api/1/net/relations',
                         headers=AUTHZ_HEADER,
                         data=RELATION_FIXTURE,
                         follow_redirects=True)
     print res.data
     body = json.loads(res.data)
     self.id = body['id']
コード例 #3
0
 def setUp(self):
     self.app = make_test_app()
     self.app.post('/api/1/networks',
                   headers=AUTHZ_HEADER,
                   data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION, h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY, h.TEST_ENTITY_SCHEMA)
     db.session.commit()
コード例 #4
0
ファイル: test_schema_api.py プロジェクト: jmorenoamor/grano
 def setUp(self):
     self.app = make_test_app()
     self.app.post('/api/1/networks',
                 headers=AUTHZ_HEADER,
                 data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION,
                   h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY,
                   h.TEST_ENTITY_SCHEMA)
     db.session.commit()
コード例 #5
0
 def make_fixtures(self):
     self.app.post('/api/1/networks',
                   headers=AUTHZ_HEADER,
                   data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION, h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY, h.TEST_ENTITY_SCHEMA)
     db.session.commit()
     res = self.app.post('/api/1/net/entities',
                         headers=AUTHZ_HEADER,
                         data=ENTITY_FIXTURE,
                         follow_redirects=True)
     body = json.loads(res.data)
     self.id = body['id']
コード例 #6
0
ファイル: manage.py プロジェクト: pudo-attic/grano-old
def sqlshell(network):
    import sys
    from grano.model import Network
    from pprint import pprint
    network = Network.by_slug(network)
    print network
    while True:
        sys.stdout.write("%s> " % network.slug)
        command = sys.stdin.readline()
        try:
            rp = network.raw_query(command)
            pprint(rp.fetchall())
        except Exception, e:
            print e
コード例 #7
0
ファイル: manage.py プロジェクト: jmorenoamor/grano
def sqlshell(network):
    import sys
    from grano.model import Network
    from pprint import pprint
    network = Network.by_slug(network)
    print network
    while True:
        sys.stdout.write("%s> " % network.slug)
        command = sys.stdin.readline()
        try:
            rp = network.raw_query(command)
            pprint(rp.fetchall())
        except Exception, e:
            print e
コード例 #8
0
ファイル: test_entity_api.py プロジェクト: jmorenoamor/grano
 def make_fixtures(self):
     self.app.post('/api/1/networks',
                 headers=AUTHZ_HEADER,
                 data=NETWORK_FIXTURE)
     network = Network.by_slug(NETWORK_FIXTURE['slug'])
     Schema.create(network, Schema.RELATION,
                   h.TEST_RELATION_SCHEMA)
     Schema.create(network, Schema.ENTITY,
                   h.TEST_ENTITY_SCHEMA)
     db.session.commit()
     res = self.app.post('/api/1/net/entities', 
                 headers=AUTHZ_HEADER,
                 data=ENTITY_FIXTURE, 
                 follow_redirects=True)
     body = json.loads(res.data)
     self.id = body['id']
コード例 #9
0
ファイル: network.py プロジェクト: jmorenoamor/grano
 def _check(value):
     if context.network and context.network.slug == value:
         return True
     if Network.by_slug(value) is not None:
         return "This network name is already in use, please choose another."
     return True
コード例 #10
0
ファイル: network_api.py プロジェクト: pudo-attic/grano-old
def _get_network(slug):
    network = Network.by_slug(slug)
    if network is None:
        raise NotFound("No such network: %s" % slug)
    require.network.read(network)
    return network
コード例 #11
0
ファイル: network_api.py プロジェクト: jmorenoamor/grano
def _get_network(slug):
    network = Network.by_slug(slug)
    if network is None:
        raise NotFound("No such network: %s" % slug)
    require.network.read(network)
    return network
コード例 #12
0
 def _check(value):
     if context.network and context.network.slug == value:
         return True
     if Network.by_slug(value) is not None:
         return "This network name is already in use, please choose another."
     return True