def setUp(self): self.client = h.make_test_app() self.network = Network.create({'title': 'Net', 'slug': 'net'}) self.schema = Schema.create(self.network, Schema.ENTITY, h.TEST_ENTITY_SCHEMA) self.rschema = Schema.create(self.network, Schema.RELATION, h.TEST_RELATION_SCHEMA) db.session.commit() self.context = ValidationContext(network=self.network)
def create(): """ Create a new network. """ require.network.create() data = request_content(request) context = ValidationContext() data = validate_network(dict(data.items()), context) network = Network.create(data) db.session.commit() url = url_for(".get", slug=network.slug) return jsonify(network, status=201, headers={"location": url})
def create(): """ Create a new network. """ require.network.create() data = request_content(request) context = ValidationContext() data = validate_network(dict(data.items()), \ context) network = Network.create(data) db.session.commit() url = url_for('.get', slug=network.slug) return jsonify(network, status=201, headers={'location': url})
def setUp(self): self.client = h.make_test_app() self.network = Network.create({'title': 'Net', 'slug': 'net'}) self.schema = Schema.create(self.network, Schema.RELATION, h.TEST_RELATION_SCHEMA) db.session.commit() self.eschema = Schema.create(self.network, Schema.ENTITY, h.TEST_ENTITY_SCHEMA) self.context = ValidationContext(network=self.network) entity = deepcopy(TEST_ENTITY) entity['network'] = self.network.slug entity = validate_entity(entity, self.eschema, self.context) entity['title'] = 'Alice' a = self.network.Entity.create(self.eschema, entity) entity['title'] = 'Bob' b = self.network.Entity.create(self.eschema, entity) TEST_RELATION['source'] = a.id TEST_RELATION['target'] = b.id db.session.commit()
def setUp(self): self.client = h.make_test_app() self.network = Network.create({'title': 'Net', 'slug': 'net'})