Commit 83859000 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

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

parent 5f8e87c0
......@@ -418,12 +418,26 @@ class ContainerGet(PithosAPITest):
container_url = join_urls(self.pithos_path, self.user, cname)
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
public1 = onames.pop()
url = join_urls(container_url, public1)
r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
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
public2 = onames.pop()
url = join_urls(container_url, public2)
......@@ -469,7 +483,7 @@ class ContainerGet(PithosAPITest):
# create child object
descendant = strnextling(public1)
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)
objects = r.content.split('\n')
if '' in objects:
......@@ -491,6 +505,29 @@ class ContainerGet(PithosAPITest):
self.assertTrue(folder 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):
cname = self.cnames[0]
url = join_urls(self.pithos_path, self.user, cname)
......
......@@ -765,7 +765,7 @@ class ModularBackend(BaseBackend):
if user != account and until:
raise NotAllowedError
objects = []
objects = set()
if shared and public:
# get shared first
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