예제 #1
0
    def test_object_show(self):
        api = self.api
        name = random_str(32)
        size = random.randint(1, 1000)
        content_hash = random_str(32)
        content_type = random_str(32)
        resp = FakeApiResponse()
        resp.headers = {
            object_headers["name"]: name,
            object_headers["size"]: str(size),
            object_headers["hash"]: content_hash,
            object_headers["mime_type"]: content_type
        }
        api.container._direct_request = Mock(return_value=(resp, {
            'properties': {}
        }))
        obj = api.object_show(self.account,
                              self.container,
                              name,
                              headers=self.headers)

        uri = "%s/content/get_properties" % self.uri_base
        params = {'acct': self.account, 'ref': self.container, 'path': name}
        api.container._direct_request.assert_called_once_with(
            'POST', uri, params=params, data=None, headers=self.headers)
        self.assertIsNotNone(obj)
예제 #2
0
 def test_object_list(self):
     api = self.api
     marker = random_str(32)
     delimiter = random_str(32)
     end_marker = random_str(32)
     prefix = random_str(32)
     limit = random.randint(1, 1000)
     name0 = random_str(32)
     name1 = random_str(32)
     resp_body = {"objects": [{"name": name0}, {"name": name1}]}
     resp = FakeApiResponse()
     resp.headers = {}
     api.container._direct_request = Mock(return_value=(resp, resp_body))
     listing = api.object_list(self.account,
                               self.container,
                               limit=limit,
                               marker=marker,
                               prefix=prefix,
                               delimiter=delimiter,
                               end_marker=end_marker,
                               headers=self.headers)
     uri = "%s/container/list" % self.uri_base
     params = {
         'acct': self.account,
         'ref': self.container,
         'marker': marker,
         'max': limit,
         'delimiter': delimiter,
         'prefix': prefix,
         'end_marker': end_marker,
         'properties': False
     }
     api.container._direct_request.assert_called_once_with(
         'GET', uri, params=params, headers=self.headers)
     self.assertEqual(len(listing['objects']), 2)
예제 #3
0
 def test_container_show(self):
     api = self.api
     resp = FakeApiResponse()
     name = random_str(32)
     cont_size = random.randint(1, 1000)
     resp.headers = {container_headers["size"]: cont_size}
     api.container._direct_request = Mock(return_value=(resp, {}))
     info = api.container_show(self.account, name, headers=self.headers)
     uri = "%s/container/show" % self.uri_base
     params = {'acct': self.account, 'ref': name}
     api.container._direct_request.assert_called_once_with(
         'GET', uri, params=params, headers=self.headers)
     self.assertEqual(info, {})