Esempio n. 1
0
 def test_request_with_client_defaults(self):
     client = atom.client.AtomPubClient(
         atom.mock_http_core.EchoHttpClient(), 'example.com',
         atom.auth.BasicAuth('Jeff', '123'))
     self.assertTrue(client.host == 'example.com')
     self.assertTrue(client.auth_token is not None)
     self.assertTrue(client.auth_token.basic_cookie == 'SmVmZjoxMjM=')
     response = client.request('GET', 'http://example.org/')
     self.assertTrue(response.getheader('Echo-Host') == 'example.org:None')
     self.assertTrue(response.getheader('Echo-Uri') == '/')
     self.assertTrue(response.getheader('Echo-Scheme') == 'http')
     self.assertTrue(response.getheader('Echo-Method') == 'GET')
     self.assertTrue(
         response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')
     response = client.request('GET', '/')
     self.assertTrue(response.getheader('Echo-Host') == 'example.com:None')
     self.assertTrue(response.getheader('Echo-Uri') == '/')
     self.assertTrue(response.getheader('Echo-Scheme') == 'http')
     self.assertTrue(
         response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')
     response = client.request('GET',
                               '/',
                               http_request=atom.http_core.HttpRequest(
                                   uri=atom.http_core.Uri(port=99)))
     self.assertTrue(response.getheader('Echo-Host') == 'example.com:99')
     self.assertTrue(response.getheader('Echo-Uri') == '/')
 def test_simple_request_with_no_client_defaults(self):
   client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())
   self.assert_(client.host is None)
   self.assert_(client.auth_token is None)
   # Make several equivalent requests.
   responses = [client.request('GET', 'http://example.org/'),
                client.request(http_request=atom.http_core.HttpRequest(
                    'http', 'example.org', uri='/', method='GET')),
                client.request('GET', 
                    http_request=atom.http_core.HttpRequest('http', 
                        'example.org', uri='/'))]
   for response in responses:
     self.assert_(response.getheader('Echo-Host') == 'example.org:None')
     self.assert_(response.getheader('Echo-Uri') == '/')
     self.assert_(response.getheader('Echo-Scheme') == 'http')
     self.assert_(response.getheader('Echo-Method') == 'GET')
Esempio n. 3
0
 def test_auth_request_with_no_client_defaults(self):
     client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())
     token = atom.auth.BasicAuth('Jeff', '123')
     response = client.request('POST', 'https://example.net:8080/',
                               auth_token=token)
     self.assertTrue(response.getheader('Echo-Host') == 'example.net:8080')
     self.assertTrue(response.getheader('Echo-Uri') == '/')
     self.assertTrue(response.getheader('Echo-Scheme') == 'https')
     self.assertTrue(response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')
     self.assertTrue(response.getheader('Echo-Method') == 'POST')
Esempio n. 4
0
 def test_auth_request_with_no_client_defaults(self):
   client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())
   token = atom.auth.BasicAuth('Jeff', '123')
   response = client.request('POST', 'https://example.net:8080/',
       auth_token=token)
   self.assert_(response.getheader('Echo-Host') == 'example.net:8080')
   self.assert_(response.getheader('Echo-Uri') == '/')
   self.assert_(response.getheader('Echo-Scheme') == 'https')
   self.assert_(response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')
   self.assert_(response.getheader('Echo-Method') == 'POST')
Esempio n. 5
0
 def test_request_with_client_defaults(self):
   client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient(), 
       'example.com', atom.auth.BasicAuth('Jeff', '123'))
   self.assert_(client.host == 'example.com')
   self.assert_(client.auth_token is not None)
   self.assert_(client.auth_token.basic_cookie == 'SmVmZjoxMjM=')
   response = client.request('GET', 'http://example.org/')
   self.assert_(response.getheader('Echo-Host') == 'example.org:None')
   self.assert_(response.getheader('Echo-Uri') == '/')
   self.assert_(response.getheader('Echo-Scheme') == 'http')
   self.assert_(response.getheader('Echo-Method') == 'GET')
   self.assert_(response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')
   response = client.request('GET', '/')
   self.assert_(response.getheader('Echo-Host') == 'example.com:None')
   self.assert_(response.getheader('Echo-Uri') == '/')
   self.assert_(response.getheader('Echo-Scheme') == 'http')
   self.assert_(response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')
   response = client.request('GET', '/', 
       http_request=atom.http_core.HttpRequest(port=99))
   self.assert_(response.getheader('Echo-Host') == 'example.com:99')