示例#1
0
 def test_get_container_list_no_body(self):
     status_codes = [204]
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes, body='')
     p = internal_proxy.InternalProxy()
     resp = p.get_container_list('a', 'c')
     self.assertEquals(resp, [])
示例#2
0
 def test_create_container(self):
     status_codes = [200]
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes)
     p = internal_proxy.InternalProxy()
     resp = p.create_container('a', 'c')
     self.assertTrue(resp)
示例#3
0
 def test_upload_file(self):
     status_codes = [200, 200]  # container PUT + object PUT
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes)
     p = internal_proxy.InternalProxy()
     with tempfile.NamedTemporaryFile() as file_obj:
         resp = p.upload_file(file_obj.name, 'a', 'c', 'o')
     self.assertTrue(resp)
示例#4
0
 def test_handle_request(self):
     status_codes = [200]
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes)
     p = internal_proxy.InternalProxy()
     req = webob.Request.blank('/')
     orig_req = internal_proxy.webob_request_copy(req)
     resp = p._handle_request(req)
     self.assertEquals(req.path_info, orig_req.path_info)
示例#5
0
 def test_upload_file_with_retries(self):
     status_codes = [200, 500, 200]  # container PUT + error + object PUT
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes)
     p = internal_proxy.InternalProxy(retries=3)
     with tempfile.NamedTemporaryFile() as file_obj:
         resp = p.upload_file(file_obj, 'a', 'c', 'o')
     self.assertTrue(resp)
     self.assertEquals(p.upload_app.call_count, 3)
示例#6
0
 def test_get_object(self):
     status_codes = [200]
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes)
     p = internal_proxy.InternalProxy()
     code, body = p.get_object('a', 'c', 'o')
     body = ''.join(body)
     self.assertEquals(code, 200)
     self.assertEquals(body, '')
示例#7
0
 def test_handle_request_with_retries(self):
     status_codes = [500, 200]
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes)
     p = internal_proxy.InternalProxy(retries=3)
     req = webob.Request.blank('/')
     orig_req = internal_proxy.webob_request_copy(req)
     resp = p._handle_request(req)
     self.assertEquals(req.path_info, orig_req.path_info)
     self.assertEquals(p.upload_app.call_count, 2)
     self.assertEquals(resp.status_int, 200)
示例#8
0
 def test_get_container_list_full(self):
     status_codes = [204]
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes, body='')
     p = internal_proxy.InternalProxy()
     resp = p.get_container_list('a',
                                 'c',
                                 marker='a',
                                 end_marker='b',
                                 limit=100,
                                 prefix='/',
                                 delimiter='.')
     self.assertEquals(resp, [])
示例#9
0
 def test_get_container_list_full_listing(self):
     status_codes = [200, 200]
     obj_a = dict(name='foo',
                  hash='foo',
                  bytes=3,
                  content_type='text/plain',
                  last_modified='2011/01/01')
     obj_b = dict(name='bar',
                  hash='bar',
                  bytes=3,
                  content_type='text/plain',
                  last_modified='2011/01/01')
     body = [json.dumps([obj_a]), json.dumps([obj_b]), json.dumps([])]
     internal_proxy.BaseApplication = DumbBaseApplicationFactory(
         status_codes, body=body)
     p = internal_proxy.InternalProxy()
     resp = p.get_container_list('a', 'c')
     expected = ['foo', 'bar']
     self.assertEquals([x['name'] for x in resp], expected)