コード例 #1
0
ファイル: test_base.py プロジェクト: helen5haha/swift
    def test_headers_to_object_info_values(self):
        headers = {"content-length": "1024", "content-type": "application/json"}
        resp = headers_to_object_info(headers.items(), 200)
        self.assertEquals(resp["length"], "1024")
        self.assertEquals(resp["type"], "application/json")

        headers["x-unused-header"] = "blahblahblah"
        self.assertEquals(resp, headers_to_object_info(headers.items(), 200))
コード例 #2
0
    def test_headers_to_object_info_values(self):
        headers = {
            'content-length': '1024',
            'content-type': 'application/json',
        }
        resp = headers_to_object_info(headers.items(), 200)
        self.assertEqual(resp['length'], '1024')
        self.assertEqual(resp['type'], 'application/json')

        headers['x-unused-header'] = 'blahblahblah'
        self.assertEqual(resp, headers_to_object_info(headers.items(), 200))
コード例 #3
0
ファイル: test_base.py プロジェクト: mahak/swift
    def test_headers_to_object_info_values(self):
        headers = {
            'content-length': '1024',
            'content-type': 'application/json',
        }
        resp = headers_to_object_info(headers.items(), 200)
        self.assertEqual(resp['length'], '1024')
        self.assertEqual(resp['type'], 'application/json')

        headers['x-unused-header'] = 'blahblahblah'
        self.assertEqual(
            resp,
            headers_to_object_info(headers.items(), 200))
コード例 #4
0
ファイル: test_base.py プロジェクト: mahak/swift
 def test_headers_to_object_info_meta(self):
     headers = {'X-Object-Meta-Whatevs': 14,
                'x-object-meta-somethingelse': 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['meta']), 2)
     self.assertEqual(resp['meta']['whatevs'], 14)
     self.assertEqual(resp['meta']['somethingelse'], 0)
コード例 #5
0
ファイル: test_base.py プロジェクト: vefimova/swift
 def test_headers_to_object_info_meta(self):
     headers = {'X-Object-Meta-Whatevs': 14,
                'x-object-meta-somethingelse': 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEquals(len(resp['meta']), 2)
     self.assertEquals(resp['meta']['whatevs'], 14)
     self.assertEquals(resp['meta']['somethingelse'], 0)
コード例 #6
0
ファイル: test_base.py プロジェクト: mahak/swift
 def test_headers_to_object_info_transient_sysmeta(self):
     headers = {get_object_transient_sysmeta('Whatevs'): 14,
                get_object_transient_sysmeta('somethingelse'): 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['transient_sysmeta']), 2)
     self.assertEqual(resp['transient_sysmeta']['whatevs'], 14)
     self.assertEqual(resp['transient_sysmeta']['somethingelse'], 0)
コード例 #7
0
ファイル: test_base.py プロジェクト: psachin/swift
 def test_headers_to_object_info_transient_sysmeta(self):
     headers = {get_object_transient_sysmeta('Whatevs'): 14,
                get_object_transient_sysmeta('somethingelse'): 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['transient_sysmeta']), 2)
     self.assertEqual(resp['transient_sysmeta']['whatevs'], 14)
     self.assertEqual(resp['transient_sysmeta']['somethingelse'], 0)
コード例 #8
0
ファイル: test_base.py プロジェクト: helen5haha/swift
 def test_headers_to_object_info_sys_meta(self):
     prefix = get_sys_meta_prefix("object")
     headers = {"%sWhatevs" % prefix: 14, "%ssomethingelse" % prefix: 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEquals(len(resp["sysmeta"]), 2)
     self.assertEquals(resp["sysmeta"]["whatevs"], 14)
     self.assertEquals(resp["sysmeta"]["somethingelse"], 0)
コード例 #9
0
 def test_headers_to_object_info_sys_meta(self):
     prefix = get_sys_meta_prefix('object')
     headers = {'%sWhatevs' % prefix: 14, '%ssomethingelse' % prefix: 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['sysmeta']), 2)
     self.assertEqual(resp['sysmeta']['whatevs'], 14)
     self.assertEqual(resp['sysmeta']['somethingelse'], 0)
コード例 #10
0
ファイル: test_base.py プロジェクト: mahak/swift
 def test_headers_to_object_info_sys_meta(self):
     prefix = get_sys_meta_prefix('object')
     headers = {'%sWhatevs' % prefix: 14,
                '%ssomethingelse' % prefix: 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['sysmeta']), 2)
     self.assertEqual(resp['sysmeta']['whatevs'], 14)
     self.assertEqual(resp['sysmeta']['somethingelse'], 0)
コード例 #11
0
ファイル: test_account_quotas.py プロジェクト: TheUtils/swift
 def __call__(self, env, start_response):
     if env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o2':
         env_key = get_object_env_key('a', 'c2', 'o2')
         env[env_key] = headers_to_object_info(self.headers, 200)
         start_response('200 OK', self.headers)
     elif env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o3':
         start_response('404 Not Found', [])
     else:
         # Cache the account_info (same as a real application)
         cache_key, env_key = _get_cache_key('a', None)
         env[env_key] = headers_to_account_info(self.headers, 200)
         start_response('200 OK', self.headers)
     return []
コード例 #12
0
    def __init__(self, headers, env, account, container, obj):
        self.headers = headers
        self.status_int = FakeResponse_status_int
        self.environ = env
        if obj:
            env_key = get_object_env_key(account, container, obj)
        else:
            cache_key, env_key = _get_cache_key(account, container)

        if account and container and obj:
            info = headers_to_object_info(headers, FakeResponse_status_int)
        elif account and container:
            info = headers_to_container_info(headers, FakeResponse_status_int)
        else:
            info = headers_to_account_info(headers, FakeResponse_status_int)
        env[env_key] = info
コード例 #13
0
ファイル: test_base.py プロジェクト: 10389030/swift
    def __init__(self, headers, env, account, container, obj):
        self.headers = headers
        self.status_int = FakeResponse_status_int
        self.environ = env
        if obj:
            env_key = get_object_env_key(account, container, obj)
        else:
            cache_key, env_key = _get_cache_key(account, container)

        if account and container and obj:
            info = headers_to_object_info(headers, FakeResponse_status_int)
        elif account and container:
            info = headers_to_container_info(headers, FakeResponse_status_int)
        else:
            info = headers_to_account_info(headers, FakeResponse_status_int)
        env[env_key] = info
コード例 #14
0
 def __call__(self, env, start_response):
     if 'swift.authorize' in env:
         aresp = env['swift.authorize'](Request(env))
         if aresp:
             return aresp(env, start_response)
     if env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o2':
         cache_key = get_cache_key('a', 'c2', 'o2')
         env.setdefault('swift.infocache', {})[cache_key] = \
             headers_to_object_info(self.headers, 200)
         start_response('200 OK', self.headers)
     elif env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o3':
         start_response('404 Not Found', [])
     else:
         # Cache the account_info (same as a real application)
         cache_key = get_cache_key('a')
         env.setdefault('swift.infocache', {})[cache_key] = \
             headers_to_account_info(self.headers, 200)
         start_response('200 OK', self.headers)
     return []
コード例 #15
0
 def __call__(self, env, start_response):
     if 'swift.authorize' in env:
         aresp = env['swift.authorize'](Request(env))
         if aresp:
             return aresp(env, start_response)
     if env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o2':
         env_key = get_object_env_key('a', 'c2', 'o2')
         env.setdefault('swift.infocache', {})[env_key] = \
             headers_to_object_info(self.headers, 200)
         start_response('200 OK', self.headers)
     elif env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o3':
         start_response('404 Not Found', [])
     else:
         # Cache the account_info (same as a real application)
         cache_key, env_key = _get_cache_key('a', None)
         env.setdefault('swift.infocache', {})[env_key] = \
             headers_to_account_info(self.headers, 200)
         start_response('200 OK', self.headers)
     return []
コード例 #16
0
ファイル: test_base.py プロジェクト: helen5haha/swift
 def test_headers_to_object_info_missing(self):
     resp = headers_to_object_info({}, 404)
     self.assertEquals(resp["status"], 404)
     self.assertEquals(resp["length"], None)
     self.assertEquals(resp["etag"], None)
コード例 #17
0
ファイル: test_base.py プロジェクト: helen5haha/swift
 def test_headers_to_object_info_meta(self):
     headers = {"X-Object-Meta-Whatevs": 14, "x-object-meta-somethingelse": 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEquals(len(resp["meta"]), 2)
     self.assertEquals(resp["meta"]["whatevs"], 14)
     self.assertEquals(resp["meta"]["somethingelse"], 0)
コード例 #18
0
ファイル: test_base.py プロジェクト: mahak/swift
 def test_headers_to_object_info_missing(self):
     resp = headers_to_object_info({}, 404)
     self.assertEqual(resp['status'], 404)
     self.assertIsNone(resp['length'])
     self.assertIsNone(resp['etag'])
コード例 #19
0
 def test_headers_to_object_info_missing(self):
     resp = headers_to_object_info({}, 404)
     self.assertEqual(resp['status'], 404)
     self.assertEqual(resp['length'], None)
     self.assertEqual(resp['etag'], None)