Commit 1879e310 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Unittest clients.pithos get container quota

parent bae347d3
......@@ -770,14 +770,20 @@ class PithosClient(PithosRestAPI):
finally:
self.container = cnt_back_up
def get_container_quota(self, container):
def get_container_quota(self, container=None):
"""
:param container: (str)
:returns: (dict)
"""
self.container = container
return filter_in(self.get_container_info(), 'X-Container-Policy-Quota')
cnt_back_up = self.container
try:
self.container = container or cnt_back_up
return filter_in(
self.get_container_info(),
'X-Container-Policy-Quota')
finally:
self.container = cnt_back_up
def get_container_info(self, until=None):
"""
......
......@@ -843,6 +843,7 @@ class Pithos(TestCase):
def test_get_container_versioning(self):
key = 'x-container-policy-versioning'
cont = 'c0n7-417'
bu_cnt = self.client.container
with patch.object(
PC,
'get_container_info',
......@@ -851,4 +852,18 @@ class Pithos(TestCase):
r = self.client.get_container_versioning(container=container)
self.assertEqual(r[key], container_info[key])
self.assertEqual(gci.mock_calls[-1], call())
self.assertEqual(bu_cnt, self.client.container)
def test_get_container_quota(self):
key = 'x-container-policy-quota'
cont = 'c0n7-417'
bu_cnt = self.client.container
with patch.object(
PC,
'get_container_info',
return_value=container_info) as gci:
for container in (None, cont):
r = self.client.get_container_quota(container=container)
self.assertEqual(r[key], container_info[key])
self.assertEqual(gci.mock_calls[-1], call())
self.assertEqual(bu_cnt, self.client.container)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment