示例#1
0
        def __call__(self,
                     method,
                     url,
                     kvdict=None,
                     quiet=False,
                     auth=None,
                     basic_auth=None,
                     cert=None,
                     fatal=True,
                     verify=None):
            kwargs = dict(kvdict=kvdict,
                          quiet=quiet,
                          auth=auth,
                          basic_auth=basic_auth,
                          cert=cert,
                          fatal=fatal)
            self.called.append((method, url, kwargs))
            reply_data = self._json_responses.get(url)
            if reply_data is not None:

                class R:
                    status_code = reply_data["status"]
                    reason = reply_data.get("reason", "OK")

                    def json(self):
                        return reply_data["json"]

                return main.HTTPReply(R())
            pytest.fail("http_api call to %r is not mocked" % (url, ))
示例#2
0
        def __call__(self,
                     method,
                     url,
                     kvdict=None,
                     quiet=False,
                     auth=None,
                     fatal=True):
            self.called.append((method, url, kvdict))
            reply_data = self._json_responses.get(url)
            if reply_data is not None:

                class R:
                    status_code = reply_data["status"]
                    reason = reply_data.get("reason", "OK")

                    def json(self):
                        return reply_data["json"]

                return main.HTTPReply(R())
            pytest.fail("http_api call to %r is not mocked" % (url, ))