Commit 83859000 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

pithos: Fix TypeError in listing shared & public by me.

parent 5f8e87c0
...@@ -418,12 +418,26 @@ class ContainerGet(PithosAPITest): ...@@ -418,12 +418,26 @@ class ContainerGet(PithosAPITest):
container_url = join_urls(self.pithos_path, self.user, cname) container_url = join_urls(self.pithos_path, self.user, cname)
onames = self.objects[cname].keys() onames = self.objects[cname].keys()
r = self.get('%s?shared=&public=&format=json' % container_url)
self.assertEqual(r.status_code, 200)
objects = json.loads(r.content)
self.assertEqual(len(objects), 0)
# publish an object # publish an object
public1 = onames.pop() public1 = onames.pop()
url = join_urls(container_url, public1) url = join_urls(container_url, public1)
r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
self.assertEqual(r.status_code, 202) self.assertEqual(r.status_code, 202)
r = self.get('%s?shared=&public=&format=json' % container_url)
self.assertEqual(r.status_code, 200)
objects = json.loads(r.content)
self.assertEqual(len(objects), 1)
self.assertEqual(objects[0]['name'], public1)
self.assertEqual(objects[0]['bytes'],
len(self.objects[cname][public1]))
self.assertTrue('x_object_public' in objects[0])
# publish another # publish another
public2 = onames.pop() public2 = onames.pop()
url = join_urls(container_url, public2) url = join_urls(container_url, public2)
...@@ -469,7 +483,7 @@ class ContainerGet(PithosAPITest): ...@@ -469,7 +483,7 @@ class ContainerGet(PithosAPITest):
# create child object # create child object
descendant = strnextling(public1) descendant = strnextling(public1)
self.upload_object(cname, descendant) self.upload_object(cname, descendant)
# request public and assert child obejct is not listed # request public and assert child object is not listed
r = self.get('%s?shared=&public=' % container_url) r = self.get('%s?shared=&public=' % container_url)
objects = r.content.split('\n') objects = r.content.split('\n')
if '' in objects: if '' in objects:
...@@ -491,6 +505,29 @@ class ContainerGet(PithosAPITest): ...@@ -491,6 +505,29 @@ class ContainerGet(PithosAPITest):
self.assertTrue(folder in objects) self.assertTrue(folder in objects)
self.assertTrue(descendant not in objects) self.assertTrue(descendant not in objects)
# unpublish public1
url = join_urls(container_url, public1)
r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false')
self.assertEqual(r.status_code, 202)
# unpublish public2
url = join_urls(container_url, public2)
r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false')
self.assertEqual(r.status_code, 202)
# unpublish folder
url = join_urls(container_url, folder)
r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false')
self.assertEqual(r.status_code, 202)
r = self.get('%s?shared=&public=' % container_url)
self.assertEqual(r.status_code, 200)
objects = r.content.split('\n')
if '' in objects:
objects.remove('')
l = sorted([shared1, shared2])
self.assertEqual(objects, l)
def test_list_objects(self): def test_list_objects(self):
cname = self.cnames[0] cname = self.cnames[0]
url = join_urls(self.pithos_path, self.user, cname) url = join_urls(self.pithos_path, self.user, cname)
......
...@@ -765,7 +765,7 @@ class ModularBackend(BaseBackend): ...@@ -765,7 +765,7 @@ class ModularBackend(BaseBackend):
if user != account and until: if user != account and until:
raise NotAllowedError raise NotAllowedError
objects = [] objects = set()
if shared and public: if shared and public:
# get shared first # get shared first
shared_paths = self._list_object_permissions( shared_paths = self._list_object_permissions(
......
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