def test_get_shared_collection_ref(road_a, road_b): output = KmlOutput('km') collection = {'join_type': 'arbitrary', 'ways': [road_a, road_b]} refs = output.get_shared_collection_refs(collection) assert len(refs) == 1 assert 'VT-555' in refs # Ensure that if a way in the collection has no refs, there are none shared. road_c = { 'id': 1002, 'tags': { 'name': 'Road B', 'highway': 'tertiary' }, 'length': 3000 } collection = {'join_type': 'arbitrary', 'ways': [road_a, road_b, road_c]} refs = output.get_shared_collection_refs(collection) assert len(refs) == 0 # Ensure that multiple refs can be returned road_c = { 'id': 1002, 'tags': { 'name': 'Road B', 'highway': 'tertiary', 'ref': 'VT-555;VT-17' }, 'length': 3000 } road_d = { 'id': 1003, 'tags': { 'name': 'Road A', 'highway': 'tertiary', 'ref': 'VT-555;VT-17' }, 'length': 100 } road_e = { 'id': 1003, 'tags': { 'name': 'Road A', 'highway': 'tertiary', 'ref': 'VT-555;US-30;VT-17' }, 'length': 100 } collection = {'join_type': 'arbitrary', 'ways': [road_c, road_d, road_e]} refs = output.get_shared_collection_refs(collection) assert len(refs) == 2 assert 'VT-555' in refs assert 'VT-17' in refs
def test_get_shared_collection_ref(road_a, road_b): output = KmlOutput('km') collection = {'join_type': 'arbitrary', 'ways': [road_a, road_b]} refs = output.get_shared_collection_refs(collection) assert len(refs) == 1 assert 'VT-555' in refs # Ensure that if a way in the collection has no refs, there are none shared. road_c = {'id': 1002, 'tags': { 'name': 'Road B', 'highway': 'tertiary'}, 'length': 3000} collection = {'join_type': 'arbitrary', 'ways': [road_a, road_b, road_c]} refs = output.get_shared_collection_refs(collection) assert len(refs) == 0 # Ensure that multiple refs can be returned road_c = {'id': 1002, 'tags': { 'name': 'Road B', 'highway': 'tertiary', 'ref': 'VT-555;VT-17'}, 'length': 3000} road_d = {'id': 1003, 'tags': { 'name': 'Road A', 'highway': 'tertiary', 'ref': 'VT-555;VT-17'}, 'length': 100} road_e = {'id': 1003, 'tags': { 'name': 'Road A', 'highway': 'tertiary', 'ref': 'VT-555;US-30;VT-17'}, 'length': 100} collection = {'join_type': 'arbitrary', 'ways': [road_c, road_d, road_e]} refs = output.get_shared_collection_refs(collection) assert len(refs) == 2 assert 'VT-555' in refs assert 'VT-17' in refs