def step_impl_then_get_file_meta(context): assert len( apply_path( parse_json_response(context.response), 'filemeta' ).items() ) > 0 'expected non empty metadata dictionary'
def step_impl_then_get_rendition_with_mimetype(context, name, mimetype): expect_json_contains(context.response, 'renditions') renditions = apply_path(parse_json_response(context.response), 'renditions') assert isinstance(renditions, dict), 'expected dict for image renditions' desc = renditions[name] assert isinstance(desc, dict), 'expected dict for rendition description' assert 'href' in desc, 'expected href in rendition description' we_can_fetch_a_file(context, desc['href'], mimetype)
def step_impl_then_get_renditions(context, type): expect_json_contains(context.response, 'renditions') renditions = apply_path(parse_json_response(context.response), 'renditions') assert isinstance(renditions, dict), 'expected dict for image renditions' for rend_name in context.app.config['RENDITIONS'][type]: desc = renditions[rend_name] assert isinstance(desc, dict), 'expected dict for rendition description' assert 'href' in desc, 'expected href in rendition description' assert 'media' in desc, 'expected media identifier in rendition description' we_can_fetch_a_file(context, desc['href'], 'image/jpeg')
def import_rendition(context, rendition_name=None): rv = parse_json_response(context.response) headers = [('Content-Type', 'multipart/form-data')] headers = unique_headers(headers, context.headers) context._id = rv['_id'] context.renditions = rv['renditions'] data = {'media_archive_guid': rv['_id'], 'href': external_url} if rendition_name: data['rendition_name'] = rendition_name context.response = context.client.post('/archive_media/import_media', data=data, headers=headers) assert_200(context.response)
def import_rendition(context, rendition_name=None): rv = parse_json_response(context.response) headers = [('Content-Type', 'multipart/form-data')] headers = unique_headers(headers, context.headers) context._id = rv['_id'] context.renditions = rv['renditions'] data = {'media_archive_guid': rv['_id'], 'href': external_url} if rendition_name: data['rendition_name'] = rendition_name context.response = context.client.post(get_prefixed_url(context.app, '/archive_media/import_media'), data=data, headers=headers) assert_200(context.response)
def then_item_is_assigned(context, item_id): context.response = context.client.get('/archive/%s' % item_id, headers=context.headers) assert_200(context.response) resp = parse_json_response(context.response) assert resp['task'].get('user', None) is not None, 'item is not assigned'
def then_item_is_locked(context, item_id): context.response = context.client.get('/archive/%s' % item_id, headers=context.headers) assert_200(context.response) resp = parse_json_response(context.response) assert resp['lock_user'] is not None
def then_item_is_assigned(context, item_id): resp = parse_json_response(context.response) assert resp['task'].get('user', None) is not None, 'item is not assigned'
def then_item_is_locked(context, item_id): assert_200(context.response) resp = parse_json_response(context.response) assert resp['lock_user'] is not None
def check_rendition(context, rendition_name): rv = parse_json_response(context.response) assert rv['renditions'][rendition_name] != context.renditions[ rendition_name], rv['renditions']
def check_original_rendition(context, mimetype): rv = parse_json_response(context.response) link_to_file = rv['renditions']['original']['href'] assert link_to_file we_can_fetch_a_file(context, link_to_file, mimetype)
def check_rendition(context, rendition_name): rv = parse_json_response(context.response) assert rv['renditions'][rendition_name] != context.renditions[rendition_name], rv['renditions']