-
Notifications
You must be signed in to change notification settings - Fork 53
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 #48 from shaurya-blip/master
Added Workspace Resource to the package. [UPDATED]
- Loading branch information
Showing
7 changed files
with
164 additions
and
2 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
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,34 @@ | ||
from monday.resources.base import BaseResource | ||
from monday.query_joins import (get_workspaces_query, create_workspace_query, | ||
add_users_to_workspace_query, delete_users_from_workspace_query, | ||
add_teams_to_workspace_query, delete_teams_from_workspace_query) | ||
|
||
|
||
class WorkspaceResource(BaseResource): | ||
def __init__(self, token): | ||
super().__init__(token) | ||
|
||
def get_workspaces(self): | ||
query = get_workspaces_query() | ||
return self.client.execute(query) | ||
|
||
def create_workspace(self, name, kind, description=""): | ||
query = create_workspace_query(name, kind, description) | ||
return self.client.execute(query) | ||
|
||
def add_users_to_workspace(self, workspace_id, user_ids, kind): | ||
query = add_users_to_workspace_query(workspace_id, user_ids, kind) | ||
return self.client.execute(query) | ||
|
||
def delete_users_from_workspace(self, workspace_id, user_ids): | ||
query = delete_users_from_workspace_query(workspace_id, user_ids) | ||
return self.client.execute(query) | ||
|
||
def add_teams_to_workspace(self, workspace_id, team_ids): | ||
query = add_teams_to_workspace_query(workspace_id, team_ids) | ||
return self.client.execute(query) | ||
|
||
def delete_teams_from_workspace(self, workspace_id, team_ids): | ||
query = delete_teams_from_workspace_query(workspace_id, team_ids) | ||
return self.client.execute(query) | ||
|
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,42 @@ | ||
from monday.tests.test_case_resource import BaseTestCase | ||
from monday.query_joins import (get_workspaces_query, create_workspace_query, | ||
add_users_to_workspace_query, delete_users_from_workspace_query, | ||
add_teams_to_workspace_query, delete_teams_from_workspace_query) | ||
|
||
|
||
class WorkspaceTestCase(BaseTestCase): | ||
def setUp(self): | ||
super(WorkspaceTestCase, self).setUp() | ||
|
||
def test_get_workspaces_query(self): | ||
query = get_workspaces_query() | ||
self.assertIn(query) | ||
|
||
def test_create_workspace_query(self): | ||
query = create_workspace_query(self.workspace_name, self.workspace_kind) | ||
self.assertIn(str(self.workspace_name), query) | ||
self.assertIn(str(self.workspace_kind), query) | ||
|
||
def test_add_users_to_workspace_query(self): | ||
query = add_users_to_workspace_query(self.workspace_id, self.user_ids, self.workspace_user_kind) | ||
self.assertIn(str(self.workspace_id), query) | ||
self.assertIn(str(self.user_ids), query) | ||
self.assertIn(str(self.workspace_user_kind), query) | ||
|
||
def test_delete_users_from_workspace_query(self): | ||
query = delete_users_from_workspace_query(self.workspace_id, self.user_ids) | ||
self.assertIn(str(self.workspace_id), query) | ||
self.assertIn(str(self.user_ids), query) | ||
|
||
def test_add_teams_to_workspace_query(self): | ||
query = add_teams_to_workspace_query(self.workspace_id, self.team_ids) | ||
self.assertIn(str(self.workspace_id), query) | ||
self.assertIn(str(self.team_ids), query) | ||
|
||
def test_delete_teams_from_workspace_query(self): | ||
query = delete_teams_from_workspace_query(self.workspace_id, self.team_ids) | ||
self.assertIn(str(self.workspace_id), query) | ||
self.assertIn(str(self.team_ids), query) | ||
|
||
|
||
|