def test_modify_request_using_string(self): client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient()) response = client.get('http://example.com/modified', name='value') self.assertTrue(response.getheader('Echo-Host') == 'example.com:None') self.assertTrue(response.getheader('Echo-Uri') == '/modified?name=value') self.assertTrue(response.getheader('Echo-Method') == 'GET')
def test_modify_request_using_string(self): client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient()) response = client.get('http://example.com/modified', name='value') self.assert_(response.getheader('Echo-Host') == 'example.com:None') self.assert_(response.getheader('Echo-Uri') == '/modified?name=value') self.assert_(response.getheader('Echo-Method') == 'GET')
def test_get(self): client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient()) response = client.get('http://example.com/simple') self.assertTrue(response.getheader('Echo-Host') == 'example.com:None') self.assertTrue(response.getheader('Echo-Uri') == '/simple') self.assertTrue(response.getheader('Echo-Method') == 'GET') response = client.Get(uri='http://example.com/simple2') self.assertTrue(response.getheader('Echo-Uri') == '/simple2') self.assertTrue(response.getheader('Echo-Method') == 'GET')
def test_get(self): client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient()) response = client.get('http://example.com/simple') self.assert_(response.getheader('Echo-Host') == 'example.com:None') self.assert_(response.getheader('Echo-Uri') == '/simple') self.assert_(response.getheader('Echo-Method') == 'GET') response = client.Get(uri='http://example.com/simple2') self.assert_(response.getheader('Echo-Uri') == '/simple2') self.assert_(response.getheader('Echo-Method') == 'GET')
def test_modify_request_using_object_str(self): client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient()) class RequestModifier(object): def __str__(self): return 'value' response = client.get('http://example.com/modified', name=RequestModifier()) self.assert_(response.getheader('Echo-Host') == 'example.com:None') self.assert_(response.getheader('Echo-Uri') == '/modified?name=value') self.assert_(response.getheader('Echo-Method') == 'GET')
def test_modify_request_using_args(self): client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient()) class RequestModifier(object): def modify_request(self, http_request): http_request.headers['Special'] = 'Set' response = client.get('http://example.com/modified', extra=RequestModifier()) self.assert_(response.getheader('Echo-Host') == 'example.com:None') self.assert_(response.getheader('Echo-Uri') == '/modified') self.assert_(response.getheader('Echo-Method') == 'GET') self.assert_(response.getheader('Special') == 'Set')