def test_create_fetch(self): with app.test_request_context(): ann_in = self.random_annotation() self.app.post(url_for('create_annotations'), data=jsons([ann_in])) raw = self.app.get(url_for('fetch_annotation', pid=ann_in.pid)).data ann_out = structs(raw) assert ann_out.pid == ann_in.pid assert ann_out.image == ann_in.image assert ann_out.scope == ann_in.scope assert ann_out.category == ann_in.category assert ann_out.annotator == ann_in.annotator assert ann_out.timestamp == ann_in.timestamp assert ann_out.geometry == ann_in.geometry
def test_list_annotations(self): with app.test_request_context(): ns = [0,1,2,3,100] image_pids = [gen_id(self.namespace) for _ in range(len(ns))] for (n,image_pid) in zip(ns,image_pids): # create n annotations for this image pid for _ in range(n): ann = self.random_annotation() ann.image = image_pid self.app.post(url_for('create_annotations', pid=ann.pid), data=jsons([ann])) for (n,image_pid) in zip(ns,image_pids): ann_list = structs(self.app.get(url_for('list_annotations', image_pid=image_pid)).data) # FIXME don't just check the length of the result, check the contents assert len(ann_list) == n
def jsonr(obj, ttl=None): return Response(jsons(obj), mimetype='application/json', headers=max_age(ttl))
def jsonr(whatevs): return Response(jsons(whatevs), mimetype='application/json')