diff --git a/tableauserverclient/_version.py b/tableauserverclient/_version.py index 5e73890bd..1737a980a 100644 --- a/tableauserverclient/_version.py +++ b/tableauserverclient/_version.py @@ -120,7 +120,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): dirname = os.path.basename(root) if dirname.startswith(parentdir_prefix): return { - "version": dirname[len(parentdir_prefix) :], + "version": dirname[len(parentdir_prefix):], "full-revisionid": None, "dirty": False, "error": None, @@ -187,7 +187,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " - tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)]) + tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %d @@ -204,7 +204,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): for ref in sorted(tags): # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): - r = ref[len(tag_prefix) :] + r = ref[len(tag_prefix):] if verbose: print("picking %s" % r) return { @@ -304,7 +304,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): tag_prefix, ) return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix) :] + pieces["closest-tag"] = full_tag[len(tag_prefix):] # distance: number of commits since tag pieces["distance"] = int(mo.group(2)) diff --git a/tableauserverclient/models/project_item.py b/tableauserverclient/models/project_item.py index bed6def6e..3a7d01143 100644 --- a/tableauserverclient/models/project_item.py +++ b/tableauserverclient/models/project_item.py @@ -10,6 +10,7 @@ class ProjectItem(object): class ContentPermissions: LockedToProject = "LockedToProject" ManagedByOwner = "ManagedByOwner" + LockedToProjectWithoutNested = "LockedToProjectWithoutNested" def __init__(self, name, description=None, content_permissions=None, parent_id=None): self._content_permissions = None diff --git a/test/assets/project_content_permission.xml b/test/assets/project_content_permission.xml new file mode 100644 index 000000000..18341e2ac --- /dev/null +++ b/test/assets/project_content_permission.xml @@ -0,0 +1,4 @@ + + + + diff --git a/test/test_database.py b/test/test_database.py index 4de623dae..e7c6a6fb6 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -85,7 +85,8 @@ def test_populate_data_quality_warning(self): with open(asset(GET_DQW_BY_CONTENT), 'rb') as f: response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: - m.get(self.server.databases._data_quality_warnings.baseurl + '/94441d26-9a52-4a42-b0fb-3f94792d1aac', text=response_xml) + m.get(self.server.databases._data_quality_warnings.baseurl + '/94441d26-9a52-4a42-b0fb-3f94792d1aac', + text=response_xml) single_database = TSC.DatabaseItem('test') single_database._id = '94441d26-9a52-4a42-b0fb-3f94792d1aac' @@ -101,7 +102,6 @@ def test_populate_data_quality_warning(self): self.assertEqual(str(first_dqw.created_at), "2021-04-09 18:39:54+00:00") self.assertEqual(str(first_dqw.updated_at), "2021-04-09 18:39:54+00:00") - def test_delete(self): with requests_mock.mock() as m: m.delete(self.baseurl + '/0448d2ed-590d-4fa0-b272-a2a8a24555b5', status_code=204) diff --git a/test/test_project.py b/test/test_project.py index 045f0a43e..be43b063e 100644 --- a/test/test_project.py +++ b/test/test_project.py @@ -9,6 +9,7 @@ GET_XML = asset('project_get.xml') UPDATE_XML = asset('project_update.xml') +SET_CONTENT_PERMISSIONS_XML = asset('project_content_permission.xml') CREATE_XML = asset('project_create.xml') POPULATE_PERMISSIONS_XML = 'project_populate_permissions.xml' POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML = 'project_populate_workbook_default_permissions.xml' @@ -83,6 +84,23 @@ def test_update(self): self.assertEqual('LockedToProject', single_project.content_permissions) self.assertEqual('9a8f2265-70f3-4494-96c5-e5949d7a1120', single_project.parent_id) + def test_content_permission_locked_to_project_without_nested(self): + with open(SET_CONTENT_PERMISSIONS_XML, 'rb') as f: + response_xml = f.read().decode('utf-8') + with requests_mock.mock() as m: + m.put(self.baseurl + '/cb3759e5-da4a-4ade-b916-7e2b4ea7ec86', text=response_xml) + project_item = TSC.ProjectItem(name='Test Project Permissions', + content_permissions='LockedToProjectWithoutNested', + description='Project created for testing', + parent_id='7687bc43-a543-42f3-b86f-80caed03a813') + project_item._id = 'cb3759e5-da4a-4ade-b916-7e2b4ea7ec86' + project_item = self.server.projects.update(project_item) + self.assertEqual('cb3759e5-da4a-4ade-b916-7e2b4ea7ec86', project_item.id) + self.assertEqual('Test Project Permissions', project_item.name) + self.assertEqual('Project created for testing', project_item.description) + self.assertEqual('LockedToProjectWithoutNested', project_item.content_permissions) + self.assertEqual('7687bc43-a543-42f3-b86f-80caed03a813', project_item.parent_id) + def test_update_datasource_default_permission(self): response_xml = read_xml_asset(UPDATE_DATASOURCE_DEFAULT_PERMISSIONS_XML) with requests_mock.mock() as m: