Exemplo n.º 1
0
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'
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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'
Exemplo n.º 5
0
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')
Exemplo n.º 6
0
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')
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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'
Exemplo n.º 10
0
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
Exemplo n.º 11
0
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'
Exemplo n.º 12
0
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
Exemplo n.º 13
0
def check_rendition(context, rendition_name):
    rv = parse_json_response(context.response)
    assert rv['renditions'][rendition_name] != context.renditions[
        rendition_name], rv['renditions']
Exemplo n.º 14
0
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)
Exemplo n.º 15
0
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
Exemplo n.º 16
0
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)
Exemplo n.º 17
0
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'
Exemplo n.º 18
0
def check_rendition(context, rendition_name):
    rv = parse_json_response(context.response)
    assert rv['renditions'][rendition_name] != context.renditions[rendition_name], rv['renditions']
Exemplo n.º 19
0
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