From 70aedc6ce391d126906e90d22100301e24b37293 Mon Sep 17 00:00:00 2001 From: Aleksey Ripinen Date: Fri, 27 Feb 2015 14:13:31 +0300 Subject: [PATCH] Added branches controller Added Branch object and manager. Added field branch_id to Task object. Added field autocreate_branches to Project object. Change-Id: I8eaa42f03663c4e65981129f22eec01f13d4a3f3 --- storyboardclient/tests/v1/test_branches.py | 50 ++++++++++++++++++++++ storyboardclient/tests/v1/test_tasks.py | 6 ++- storyboardclient/v1/branches.py | 29 +++++++++++++ storyboardclient/v1/client.py | 2 + storyboardclient/v1/projects.py | 1 + storyboardclient/v1/tasks.py | 1 + 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 storyboardclient/tests/v1/test_branches.py create mode 100644 storyboardclient/v1/branches.py diff --git a/storyboardclient/tests/v1/test_branches.py b/storyboardclient/tests/v1/test_branches.py new file mode 100644 index 0000000..39f691f --- /dev/null +++ b/storyboardclient/tests/v1/test_branches.py @@ -0,0 +1,50 @@ +# Copyright (c) 2015 Mirantis Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import mock + +from storyboardclient.tests import base as test_base +from storyboardclient.v1 import branches + + +class BranchesTestCase(test_base.TestCase): + + @mock.patch("storyboardclient.v1.branches.BranchesManager._list") + def test_branches_list(self, mock_private_list): + branches.BranchesManager(mock.MagicMock()).list() + + mock_private_list.assert_called_once_with( + "/branches", None) + + @mock.patch("storyboardclient.v1.branches.BranchesManager._post") + def test_branches_create(self, mock_private_post): + branches.BranchesManager(mock.MagicMock()).create( + name="test_branch", + project_id="test_project_id") + + mock_private_post.assert_called_once_with( + "/branches", + {"name": "test_branch", + "project_id": "test_project_id"}) + + @mock.patch("storyboardclient.v1.branches.BranchesManager._put") + def test_branches_update(self, mock_private_put): + branches.BranchesManager(mock.MagicMock()).update( + id="test_branch_id", + name="test_branch_updated") + + mock_private_put.assert_called_once_with( + "/branches/test_branch_id", + {"name": "test_branch_updated"}) diff --git a/storyboardclient/tests/v1/test_tasks.py b/storyboardclient/tests/v1/test_tasks.py index f102f30..78de8b0 100644 --- a/storyboardclient/tests/v1/test_tasks.py +++ b/storyboardclient/tests/v1/test_tasks.py @@ -38,13 +38,15 @@ class TasksTestCase(test_base.TestCase): tasks.TasksManager(mock.MagicMock()).create( title="test_task", story_id="test_story_id", - project_id="test_project_id") + project_id="test_project_id", + branch_id="test_branch_id") mock_private_post.assert_called_once_with( "/tasks", {"title": "test_task", "story_id": "test_story_id", - "project_id": "test_project_id"}) + "project_id": "test_project_id", + "branch_id": "test_branch_id"}) @mock.patch("storyboardclient.v1.tasks.TasksManager._put") def test_tasks_update(self, mock_private_put): diff --git a/storyboardclient/v1/branches.py b/storyboardclient/v1/branches.py new file mode 100644 index 0000000..378e292 --- /dev/null +++ b/storyboardclient/v1/branches.py @@ -0,0 +1,29 @@ +# Copyright (c) 2015 Mirantis Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from storyboardclient import base + + +class Branch(base.BaseObject): + name = None + project_id = None + expired = None + expiration_date = None + autocreated = None + + +class BranchesManager(base.BaseManager): + url_key = "branches" + resource_class = Branch \ No newline at end of file diff --git a/storyboardclient/v1/client.py b/storyboardclient/v1/client.py index a6a1691..6e10b50 100644 --- a/storyboardclient/v1/client.py +++ b/storyboardclient/v1/client.py @@ -14,6 +14,7 @@ # limitations under the License. from storyboardclient import base +from storyboardclient.v1 import branches from storyboardclient.v1 import project_groups from storyboardclient.v1 import projects from storyboardclient.v1 import stories @@ -47,6 +48,7 @@ class Client(base.BaseClient): super(Client, self).__init__(api_url=api_url, access_token=access_token) + self.branches = branches.BranchesManager(self) self.tasks = tasks.TasksManager(self) self.teams = teams.TeamsManager(self) self.projects = projects.ProjectsManager(self) diff --git a/storyboardclient/v1/projects.py b/storyboardclient/v1/projects.py index 4ada8af..7bb0fd3 100644 --- a/storyboardclient/v1/projects.py +++ b/storyboardclient/v1/projects.py @@ -20,6 +20,7 @@ class Project(base.BaseObject): name = None description = None is_active = None + autocreate_branches = None class ProjectsManager(base.BaseManager): diff --git a/storyboardclient/v1/tasks.py b/storyboardclient/v1/tasks.py index d27ea3d..d7e4e1e 100644 --- a/storyboardclient/v1/tasks.py +++ b/storyboardclient/v1/tasks.py @@ -24,6 +24,7 @@ class Task(base.BaseObject): story_id = None project_id = None assignee_id = None + branch_id = None priority = None