def create(self, acl=None): '''Creates a directory, optionally include Acl argument to set permissions''' parent, name = getParentAndBase(self.path) json = { 'name': name } if acl is not None: json['acl'] = acl.to_api_param() response = self.client.postJsonHelper(DataDirectory._getUrl(parent), json, False) if (response.status_code != 200): raise Exception("Directory creation failed: " + str(response.content))
def test_getParentAndBase(self): self.assertEqual(('a/b', 'c'), getParentAndBase('a/b/c')) self.assertEqual(('a/b', 'c'), getParentAndBase('a/b/c///')) self.assertEqual(('//a//b', 'c'), getParentAndBase('//a//b////c///'))
def getName(self): _, name = getParentAndBase(self.path) return name
def test_getParentAndBase(self): self.assertEqual(('a/b', 'c'), getParentAndBase('a/b/c')) self.assertEqual(('data://foo', 'bar'), getParentAndBase('data://foo/bar')) self.assertEqual(('data:///', 'foo'), getParentAndBase('data:///foo')) self.assertEqual(('data://', 'foo'), getParentAndBase('data://foo'))