def __respond(self, path):
        """ **Not for user.
        Appends path to URL and calls `requests` for API populating request arguments.
        Raises error  based on status.
        Return json data.

        Args:
            path(str): This should be path that was provided to method.
        """
        self.url = path
        request_args = self.request_args._asdict()
        request_args.update(url=self.url)
        request_args.update(headers=self.headers)
        response = requests.request(**request_args)
        try:
            json_response = response.json()
        except ValueError:
            json_response = {'message': response.text}
        if not response.ok:
            pv_exceptions.raise_valid_error(status_code=response.status_code, **json_response)
        return json_response
 def test_raise_valid_exception(self, pv_messages):
     server_error = pv_messages.ERROR.SERVER
     auth_error = pv_messages.ERROR.AUTH
     notfound_error = pv_messages.ERROR.NOTFOUND
     some_error = pv_messages.ERROR.RANDOM
     bad_error = pv_messages.ERROR.BAD
     with pytest.raises(exceptions.PicovicoServerError) as excinfo:
         exceptions.raise_valid_error(status_code=501, **server_error)
     assert excinfo.value.status >= 500
     with pytest.raises(exceptions.PicovicoNotFound) as excinfo:
         exceptions.raise_valid_error(status_code=404, **notfound_error)
     assert excinfo.value.status == 404
     with pytest.raises(exceptions.PicovicoUnauthorized) as excinfo:
         exceptions.raise_valid_error(status_code=401, **auth_error)
     assert excinfo.value.status == 401
     with pytest.raises(exceptions.PicovicoRequestError) as excinfo:
         exceptions.raise_valid_error(status_code=400, **bad_error)
     assert excinfo.value.status == 400
     with pytest.raises(exceptions.PicovicoRequestError) as excinfo:
         exceptions.raise_valid_error(status_code=415, **some_error)
     assert excinfo.value.status == 415