示例#1
0
 def test_GET_after_PUT(self):
     client = http.HttpClient()
     for i in range(10):
         path = self.URI_BASE + '/file.%(i)d.txt' % locals()
         client.PUT(path, self.RESPONSE + str(i))
         self.assertEquals(client.GET(path), self.RESPONSE + str(i))
示例#2
0
 def test_unauthenticated_POST(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/auth'
     self.assertRaises(http.Unauthorized, client.POST, path, self.DUMMYDATA)
示例#3
0
 def test_PUT(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/noauth'
     self.assertEquals(client.PUT(path, self.DUMMYDATA), 'PUT OK')
示例#4
0
 def test_POST(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/noauth'
     self.assertEquals(client.POST(path, self.DUMMYDATA),
                       self.DUMMYDATA.encode('rot13'))
示例#5
0
 def test_authenticated_POST(self):
     client = http.HttpClient(self.USERNAME, self.PASSWORD)
     path = self.URI_BASE + '/auth'
     self.assertEquals(client.POST(path, self.DUMMYDATA),
                       self.DUMMYDATA.encode('rot13'))
示例#6
0
 def test_authenticated_GET(self):
     client = http.HttpClient(self.USERNAME, self.PASSWORD)
     path = self.URI_BASE + '/auth'
     self.assertEquals(client.GET(path), self.RESPONSE)
示例#7
0
 def test_unauthenticated_GET(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/auth'
     self.assertRaises(http.Unauthorized, client.GET, path)
示例#8
0
 def test_GET(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/noauth'
     self.assertEquals(client.GET(path), self.RESPONSE)
示例#9
0
 def test_BadRequest(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/badrequest'
     self.assertRaises(http.BadRequest, client.GET, path)
示例#10
0
 def test_Unauthorized(self):
     client = http.HttpClient('invalid-username', 'invalid-password')
     path = self.URI_BASE + '/auth'
     self.assertRaises(http.Unauthorized, client.GET, path)
示例#11
0
 def test_NotFound(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/notfound'
     self.assertRaises(http.NotFound, client.GET, path)
示例#12
0
 def test_UnknownResponse(self):
     client = http.HttpClient()
     path = self.URI_BASE + '/invaliderror'
     self.assertRaises(http.UnknownResponse, client.GET, path)