Ejemplo n.º 1
0
def test_hinder_collection_last_page(siren_collection):
    result = hinder(siren_collection, path='/captains', page=3, last_page=3)
    rels = [i['rel'] for i in result['links']]
    assert ['self'] in rels
    assert ['previous'] in rels
    assert ['last'] in rels
    assert ['next'] not in rels
Ejemplo n.º 2
0
def test_hinder_collection_pagination_hrefs(siren_collection):
    result = hinder(siren_collection, path='/captains', page=2)
    d = {}
    for i in result['links']:
        d[i['rel'][0]] = i['href']
    assert d['self'] == '/captains?page=2'
    assert d['next'] == '/captains?page=3'
    assert d['previous'] == '/captains?page=1'
Ejemplo n.º 3
0
def test_hinder_collection_properties(siren_collection):
    result = hinder(siren_collection)
    assert result['properties']['count'] == len(siren_collection)
Ejemplo n.º 4
0
def test_hinder_resource_class(siren_resource):
    result = hinder(siren_resource, cls='captain')
    assert 'class' in result
    assert result['class'] == ['captain']
Ejemplo n.º 5
0
def test_hinder_resource_links(siren_resource):
    result = hinder(siren_resource, path='/captains')
    assert 'links' in result
    assert result['links'][0]['rel'] == ['self']
    assert result['links'][0]['href'] == '/captains'
Ejemplo n.º 6
0
def test_hinder_resource_properties(siren_resource):
    result = hinder(siren_resource)
    assert 'properties' in result
    for key in siren_resource:
        assert result['properties'][key] == siren_resource[key]
Ejemplo n.º 7
0
def test_hinder_collection_entities_href(siren_collection):
    result = hinder(siren_collection, path='/captains', page=3, last_page=3)
    for item in result['entities']:
        item_id = item['properties']['id']
        assert '/captains/' + str(item_id) in item['href']
Ejemplo n.º 8
0
def test_hinder_collection_entities_rel(siren_collection):
    result = hinder(siren_collection, path='/captains', page=3, last_page=3)
    for item in result['entities']:
        assert item['rel'] == ['item']
Ejemplo n.º 9
0
def test_hinder_collection_entities_properties(siren_collection):
    result = hinder(siren_collection)
    properties = siren_collection[0].keys()
    assert len(result['entities']) == len(siren_collection)
    for item in result['entities']:
        assert item['properties'].keys() == properties
Ejemplo n.º 10
0
def test_hinder_collection_last_page_next(siren_collection):
    result = hinder(siren_collection, path='/captains', page=1, last_page=3)
    rels = [i['rel'] for i in result['links']]
    assert ['next'] in rels
Ejemplo n.º 11
0
def test_hinder_collection_pagination_rels(siren_collection):
    result = hinder(siren_collection, path='/captains', page=2)
    rels = [i['rel'] for i in result['links']]
    assert ['self'] in rels
    assert ['next'] in rels
    assert ['previous'] in rels