def valhalla_class_without_url_test(): with pytest.raises(ValueError) as excinfo: valhalla_without_url = { 'class': 'jormungandr.street_network.valhalla.Valhalla' } StreetNetwork.get_street_network(None, valhalla_without_url) assert 'service_url is invalid, you give None' in str(excinfo.value)
def valhalla_class_without_url_test(): with pytest.raises(ValueError) as excinfo: valhalla_without_url = [{ 'modes': ALL_MODES, 'class': VALHALLA_CLASS, }] StreetNetwork.get_street_network_services(None, valhalla_without_url) assert 'service_url None is not a valid url' in str(excinfo.value)
def valhalla_class_with_invalid_url_test(): with pytest.raises(ValueError) as excinfo: kraken_conf = { 'class': 'jormungandr.street_network.valhalla.Valhalla', 'args': { "service_url": "bob" } } StreetNetwork.get_street_network(None, kraken_conf) assert 'service_url is invalid, you give bob' in str(excinfo.value)
def valhalla_class_with_invalid_url_test(): with pytest.raises(ValueError) as excinfo: kraken_conf = [{ 'modes': ALL_MODES, 'class': VALHALLA_CLASS, 'args': { "service_url": "bob" } }] StreetNetwork.get_street_network_services(None, kraken_conf) assert 'service_url bob is not a valid url' in str(excinfo.value)
def valhalla_class_with_class_not_exist_test(): with pytest.raises(ConfigException) as excinfo: kraken_conf = [{ 'class': 'jormungandr.street_network.valhalla.bob', 'modes': ['walking'], 'args': { "service_url": "http://localhost:8002", "costing_options": { "pedestrian": { "walking_speed": 50.1 } } } }] StreetNetwork.get_street_network_services(None, kraken_conf)
def street_network_without_class_test(): with pytest.raises(KeyError) as excinfo: kraken_conf = { 'args': { "service_url": "http://localhost:8002", "costing_options": { "pedestrian": { "walking_speed": 50.1 } } } } StreetNetwork.get_street_network(None, kraken_conf) assert 'impossible to build a routing, missing mandatory field in configuration' in str( excinfo.value)
def streetnetwork_service_without_modes_test(): with pytest.raises(KeyError) as excinfo: kraken_conf = [{ 'class': 'jormungandr.street_network.valhalla.bob', 'args': { "service_url": "http://localhost:8002", "costing_options": { "pedestrian": { "walking_speed": 50.1 } } } }] StreetNetwork.get_street_network_services(None, kraken_conf) assert 'impossible to build a StreetNetwork, missing mandatory field in configuration: modes' \ in str(excinfo.value)
def valhalla_class_with_class_not_exist_test(): with pytest.raises(AttributeError) as excinfo: kraken_conf = { 'class': 'jormungandr.street_network.valhalla.bob', 'args': { "service_url": "http://localhost:8002", "costing_options": { "pedestrian": { "walking_speed": 50.1 } } } } StreetNetwork.get_street_network(None, kraken_conf) assert 'impossible to build StreetNetwork, cannot find class: jormungandr.street_network.valhalla.bob' \ in str(excinfo.value)
def valhalla_class_with_class_invalid_test(): with pytest.raises(ValueError) as excinfo: kraken_conf = { 'class': 'jormungandr', 'args': { "service_url": "http://localhost:8002", "costing_options": { "pedestrian": { "walking_speed": 50.1 } } } } StreetNetwork.get_street_network(None, kraken_conf) assert 'impossible to build StreetNetwork, wrongly formated class: jormungandr' in str( excinfo.value)
def valhalla_class_without_costing_options_test(): kraken_conf = { 'class': 'jormungandr.street_network.valhalla.Valhalla', 'args': { "service_url": "http://localhost:8002", } } assert isinstance(StreetNetwork.get_street_network(None, kraken_conf), Valhalla)
def valhalla_class_without_costing_options_test(): kraken_conf = [{ 'modes': ALL_MODES, 'class': VALHALLA_CLASS, 'args': { "service_url": "http://localhost:8002" } }] services = StreetNetwork.get_street_network_services(None, kraken_conf) assert len(services) == 1 assert isinstance(services[0], Valhalla)
def valhalla_class_with_empty_costing_options_test(): kraken_conf = [{ 'modes': ALL_MODES, 'class': VALHALLA_CLASS, 'args': { "service_url": "http://localhost:8002", "costing_options": {} } }] services = StreetNetwork.get_street_network_services(None, kraken_conf) for mode in ALL_MODES: assert isinstance(services[mode], Valhalla)
def valhalla_class_with_url_valid_test(): kraken_conf = { 'class': 'jormungandr.street_network.valhalla.Valhalla', 'args': { "service_url": "http://localhost:8002", "costing_options": { "pedestrian": { "walking_speed": 50.1 } } } } assert isinstance(StreetNetwork.get_street_network(None, kraken_conf), Valhalla)
def valhalla_class_with_url_valid_test(): kraken_conf = [{ 'modes': ALL_MODES, 'class': VALHALLA_CLASS, 'args': { "service_url": "http://localhost:8002", "costing_options": { "pedestrian": { "walking_speed": 50.1 } } } }] services = StreetNetwork.get_street_network_services(None, kraken_conf) assert len(services) == 1 assert isinstance(services[0], Valhalla)
def kraken_class_test(): kraken_conf = [{'modes': ALL_MODES, 'class': KRAKEN_CLASS}] services = StreetNetwork.get_street_network_services(None, kraken_conf) assert len(services) == 1 assert isinstance(services[0], Kraken)
def kraken_class_test(): kraken_conf = {'class': 'jormungandr.street_network.kraken.Kraken'} assert isinstance(StreetNetwork.get_street_network(None, kraken_conf), Kraken)