Skip to content

Commit

Permalink
Added call that copies a chart from a workspace to another workspace (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Oct 16, 2023
1 parent 34aa9ca commit c403296
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions seatsio/charts/chartsClient.py
Expand Up @@ -54,6 +54,21 @@ def copy_to_workspace(self, chart_key, to_workspace_key):
toWorkspaceKey=to_workspace_key) \
.post_empty_and_return(Chart)

def copy_from_workspace_to(self, chart_key, from_workspace_key, to_workspace_key):
return self.http_client \
.url("/charts/{key}/version/published/actions/copy/from/{fromWorkspaceKey}/to{toWorkspaceKey}",
key=chart_key,
toWorkspaceKey=to_workspace_key) \
.post_empty_and_return(Chart)

def copy_from_workspace_to(self, chart_key, from_workspace_key, to_workspace_key):
return self.http_client \
.url("/charts/{key}/version/published/actions/copy/from/{fromWorkspaceKey}/to/{toWorkspaceKey}",
key=chart_key,
fromWorkspaceKey=from_workspace_key,
toWorkspaceKey=to_workspace_key) \
.post_empty_and_return(Chart)

def copy_draft_version(self, key):
return self.http_client \
.url("/charts/{key}/version/draft/actions/copy", key=key) \
Expand Down
18 changes: 18 additions & 0 deletions tests/charts/testCopyChartFromWorkspaceTo.py
@@ -0,0 +1,18 @@
from tests.seatsioClientTest import SeatsioClientTest
from tests.util.asserts import assert_that


class CopyChartToWorkspaceTest(SeatsioClientTest):

def test(self):
chart = self.client.charts.create("my chart", "BOOTHS")
to_workspace = self.client.workspaces.create("my ws")

copied_chart = self.client.charts.copy_from_workspace_to(chart.key, self.workspace.key, to_workspace.key)

workspace_client = self.create_client(to_workspace.secret_key, None)
assert_that(copied_chart.name).is_equal_to("my chart")
retrieved_chart = workspace_client.charts.retrieve(copied_chart.key)
assert_that(retrieved_chart.name).is_equal_to("my chart")
drawing = workspace_client.charts.retrieve_published_version(copied_chart.key)
assert_that(drawing.venueType).is_equal_to("BOOTHS")
1 change: 1 addition & 0 deletions tests/seatsioClientTest.py
Expand Up @@ -17,6 +17,7 @@ def setUp(self):
super(SeatsioClientTest, self).setUp()
company = self.create_test_company()
self.user = company["admin"]
self.workspace = seatsio.Workspace.create(company["workspace"])
self.client = self.create_client(self.user["secretKey"], None)

def tearDown(self):
Expand Down

0 comments on commit c403296

Please sign in to comment.