def enable_patching(self): if not HTTPretty.is_enabled(): HTTPretty.enable() for method in HTTPretty.METHODS: for backend in self.backends_for_urls.values(): for key, value in backend.urls.items(): HTTPretty.register_uri( method=method, uri=re.compile(key), body=convert_httpretty_response(value), )
def start(self): self.backend.reset() HTTPretty.enable() for method in HTTPretty.METHODS: for key, value in self.backend.urls.iteritems(): HTTPretty.register_uri( method=method, uri=re.compile(key), body=value, ) # Mock out localhost instance metadata HTTPretty.register_uri( method=method, uri=re.compile('http://169.254.169.254/latest/meta-data/.*'), body=metadata_response )
def disable_patching(self): HTTPretty.disable() HTTPretty.reset()
def reset(self): HTTPretty.reset()
def stop(self): HTTPretty.disable()