class WhenMakingRequests: def setup(self): self.web_client = Dingus() self.web_client.request.return_value = ['application/fake', ''] self.link = Link('/', self.web_client) def should_forward_get_requests_to_web_client(self): self.link.get() assert self.web_client.calls('request', 'GET', '/', False, None).one() def should_forward_put_requests_to_web_client(self): self.link.put('putdata') assert self.web_client.calls('request', 'PUT', '/', False, 'putdata').one() def should_forward_post_requests_to_web_client(self): self.link.post('postdata') assert self.web_client.calls('request', 'POST', '/', False, 'postdata').one() def should_forward_delete_requests_to_web_client(self): self.link.delete() assert self.web_client.calls('request', 'DELETE', '/', False, None).one()
def setup(self): self.web_client = Dingus() self.web_client.request.return_value = ['application/fake', ''] link = Link('/foo/%s/bar', self.web_client) link.get('variable')