Exemple #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
Exemple #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'
Exemple #3
0
def test_hinder_collection_properties(siren_collection):
    result = hinder(siren_collection)
    assert result['properties']['count'] == len(siren_collection)
Exemple #4
0
def test_hinder_resource_class(siren_resource):
    result = hinder(siren_resource, cls='captain')
    assert 'class' in result
    assert result['class'] == ['captain']
Exemple #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'
Exemple #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]
Exemple #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']
Exemple #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']
Exemple #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
Exemple #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
Exemple #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