Revision 1879e310
b/kamaki/clients/pithos.py | ||
---|---|---|
770 | 770 |
finally: |
771 | 771 |
self.container = cnt_back_up |
772 | 772 |
|
773 |
def get_container_quota(self, container): |
|
773 |
def get_container_quota(self, container=None):
|
|
774 | 774 |
""" |
775 | 775 |
:param container: (str) |
776 | 776 |
|
777 | 777 |
:returns: (dict) |
778 | 778 |
""" |
779 |
self.container = container |
|
780 |
return filter_in(self.get_container_info(), 'X-Container-Policy-Quota') |
|
779 |
cnt_back_up = self.container |
|
780 |
try: |
|
781 |
self.container = container or cnt_back_up |
|
782 |
return filter_in( |
|
783 |
self.get_container_info(), |
|
784 |
'X-Container-Policy-Quota') |
|
785 |
finally: |
|
786 |
self.container = cnt_back_up |
|
781 | 787 |
|
782 | 788 |
def get_container_info(self, until=None): |
783 | 789 |
""" |
b/kamaki/clients/test/pithos.py | ||
---|---|---|
843 | 843 |
def test_get_container_versioning(self): |
844 | 844 |
key = 'x-container-policy-versioning' |
845 | 845 |
cont = 'c0n7-417' |
846 |
bu_cnt = self.client.container |
|
846 | 847 |
with patch.object( |
847 | 848 |
PC, |
848 | 849 |
'get_container_info', |
... | ... | |
851 | 852 |
r = self.client.get_container_versioning(container=container) |
852 | 853 |
self.assertEqual(r[key], container_info[key]) |
853 | 854 |
self.assertEqual(gci.mock_calls[-1], call()) |
855 |
self.assertEqual(bu_cnt, self.client.container) |
|
854 | 856 |
|
857 |
def test_get_container_quota(self): |
|
858 |
key = 'x-container-policy-quota' |
|
859 |
cont = 'c0n7-417' |
|
860 |
bu_cnt = self.client.container |
|
861 |
with patch.object( |
|
862 |
PC, |
|
863 |
'get_container_info', |
|
864 |
return_value=container_info) as gci: |
|
865 |
for container in (None, cont): |
|
866 |
r = self.client.get_container_quota(container=container) |
|
867 |
self.assertEqual(r[key], container_info[key]) |
|
868 |
self.assertEqual(gci.mock_calls[-1], call()) |
|
869 |
self.assertEqual(bu_cnt, self.client.container) |
Also available in: Unified diff