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