-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from seatsio/matti/workspace-calls
Added workspace calls
- Loading branch information
Showing
16 changed files
with
133 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class UpdateWorkspaceRequest: | ||
def __init__(self, name): | ||
self.name = name |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class CreateWorkspaceRequest: | ||
def __init__(self, name, is_test=None): | ||
self.name = name | ||
if is_test is not None: | ||
self.isTest = is_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from seatsio.domain import Workspace | ||
from seatsio.pagination.listableObjectsClient import ListableObjectsClient | ||
from seatsio.pagination.lister import Lister | ||
from seatsio.pagination.pageFetcher import PageFetcher | ||
from seatsio.workspaces.UpdateWorkspaceRequest import UpdateWorkspaceRequest | ||
from seatsio.workspaces.createWorkspaceRequest import CreateWorkspaceRequest | ||
|
||
|
||
class WorkspacesClient(ListableObjectsClient): | ||
|
||
def __init__(self, http_client): | ||
ListableObjectsClient.__init__(self, http_client, Workspace, "/workspaces") | ||
|
||
def create(self, name, is_test=None): | ||
response = self.http_client.url("/workspaces").post( | ||
CreateWorkspaceRequest(name, is_test)) | ||
return Workspace(response.json()) | ||
|
||
def update(self, key, name): | ||
self.http_client.url("/workspaces/{key}", key=key).post( | ||
UpdateWorkspaceRequest(name)) | ||
|
||
def retrieve(self, key): | ||
return self.http_client.url("/workspaces/{key}", key=key).get_as(Workspace) | ||
|
||
def list(self, filter=None): | ||
page_fetcher = PageFetcher(Workspace, self.http_client, "/workspaces") | ||
|
||
if filter is not None: | ||
page_fetcher.set_query_param("filter", filter) | ||
|
||
return Lister(page_fetcher).list() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setup( | ||
name='seatsio', | ||
version='v47', | ||
version='v48', | ||
description='The official Seats.io Python client library', | ||
author='The seats.io dev team', | ||
author_email='[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from tests.seatsioClientTest import SeatsioClientTest | ||
from tests.util.asserts import assert_that | ||
|
||
|
||
class CreateWorkspaceTest(SeatsioClientTest): | ||
|
||
def test_create_workspace(self): | ||
workspace = self.client.workspaces.create("my workspace") | ||
|
||
assert_that(workspace.id).is_not_zero() | ||
assert_that(workspace.name).is_equal_to("my workspace") | ||
assert_that(workspace.key).is_not_none() | ||
assert_that(workspace.secret_key).is_not_none() | ||
assert_that(workspace.is_test).is_false() | ||
|
||
def test_create_test_workspace(self): | ||
workspace = self.client.workspaces.create("my workspace", True) | ||
|
||
assert_that(workspace.id).is_not_zero() | ||
assert_that(workspace.name).is_equal_to("my workspace") | ||
assert_that(workspace.key).is_not_none() | ||
assert_that(workspace.secret_key).is_not_none() | ||
assert_that(workspace.is_test).is_true() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from tests.seatsioClientTest import SeatsioClientTest | ||
from tests.util.asserts import assert_that | ||
|
||
|
||
class ListAllWorkspacesTest(SeatsioClientTest): | ||
|
||
def test(self): | ||
self.client.workspaces.create("ws1") | ||
self.client.workspaces.create("ws2") | ||
self.client.workspaces.create("ws3") | ||
|
||
workspaces = self.client.workspaces.list() | ||
|
||
assert_that(workspaces).extracting("name").contains_exactly("ws3", "ws2", "ws1", "Main workspace") | ||
|
||
def test_filter(self): | ||
self.client.workspaces.create("someWorkspace") | ||
self.client.workspaces.create("anotherWorkspace") | ||
self.client.workspaces.create("anotherAnotherWorkspace") | ||
|
||
workspaces = self.client.workspaces.list("another") | ||
|
||
assert_that(workspaces).extracting("name").contains_exactly("anotherAnotherWorkspace", "anotherWorkspace") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from tests.seatsioClientTest import SeatsioClientTest | ||
from tests.util.asserts import assert_that | ||
|
||
|
||
class UpdateWorkspaceTest(SeatsioClientTest): | ||
|
||
def test(self): | ||
workspace = self.client.workspaces.create("my workspace") | ||
|
||
retrieved_workspace = self.client.workspaces.retrieve(workspace.key) | ||
assert_that(retrieved_workspace.id).is_not_zero() | ||
assert_that(retrieved_workspace.name).is_equal_to("my workspace") | ||
assert_that(retrieved_workspace.key).is_not_none() | ||
assert_that(retrieved_workspace.secret_key).is_not_none() | ||
assert_that(retrieved_workspace.is_test).is_false() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from tests.seatsioClientTest import SeatsioClientTest | ||
from tests.util.asserts import assert_that | ||
|
||
|
||
class UpdateWorkspaceTest(SeatsioClientTest): | ||
|
||
def test(self): | ||
workspace = self.client.workspaces.create("my workspace") | ||
|
||
self.client.workspaces.update(workspace.key, "my ws") | ||
|
||
retrieved_workspace = self.client.workspaces.retrieve(workspace.key) | ||
assert_that(retrieved_workspace.id).is_not_zero() | ||
assert_that(retrieved_workspace.name).is_equal_to("my ws") | ||
assert_that(retrieved_workspace.key).is_not_none() | ||
assert_that(retrieved_workspace.secret_key).is_not_none() | ||
assert_that(retrieved_workspace.is_test).is_false() |