def test_custom_messages(): fakeurl = 'https://example.com' responses.add(responses.GET, fakeurl, status=401) service = base.Service() response = service.session.get(fakeurl) assert service.handle_http_error(response) is None with pytest.raises(mapbox.errors.HTTPError) as exc: assert service.handle_http_error(response, custom_messages={401: "error"}) assert exc.value.message == 'error' with pytest.raises(requests.exceptions.HTTPError) as exc: assert service.handle_http_error(response, raise_for_status=True) assert "401" in exc.value.message
def test_configured_host(monkeypatch): monkeypatch.setenv('MAPBOX_HOST', 'example.com') service = base.Service() assert service.host == 'example.com'
def test_default_host(): service = base.Service() assert service.host == 'api.mapbox.com'
def test_class_attrs(): """Get expected class attr values""" serv = base.Service() assert serv.api_name == 'hors service' assert serv.api_version == 'v0' assert serv.baseuri == 'https://api.mapbox.com/hors service/v0'