Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tableauserverclient/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions tableauserverclient/models/project_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/assets/project_content_permission.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.3.xsd">
<project id="cb3759e5-da4a-4ade-b916-7e2b4ea7ec86" name="Test Project Permissions" description="Project created for testing" contentPermissions="LockedToProjectWithoutNested" parentProjectId="7687bc43-a543-42f3-b86f-80caed03a813" />
</tsResponse>
4 changes: 2 additions & 2 deletions test/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions test/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down