diff --git a/storyboardclient/tests/v1/test_stories.py b/storyboardclient/tests/v1/test_stories.py index db56310..79d8c8d 100644 --- a/storyboardclient/tests/v1/test_stories.py +++ b/storyboardclient/tests/v1/test_stories.py @@ -117,3 +117,13 @@ class StoriesTestCase(test_base.TestCase): mock_private_put.assert_called_once_with( "/stories/test_story_id/comments/comment_id", {"content": "updated_test_comment"}) + + @mock.patch("storyboardclient.v1.tags.TagsNestedManager._put") + def test_stories_update_tags(self, mock_private_put): + test_story = stories.Story(mock.MagicMock(), + info={"id": "test_story_id"}) + test_story.tags_manager.update(["first_test_tag", "second_test_tag"]) + + mock_private_put.assert_called_once_with( + "/stories/test_story_id/tags", + ["first_test_tag", "second_test_tag"]) diff --git a/storyboardclient/tests/v1/test_tags.py b/storyboardclient/tests/v1/test_tags.py new file mode 100644 index 0000000..2c5d1eb --- /dev/null +++ b/storyboardclient/tests/v1/test_tags.py @@ -0,0 +1,37 @@ +# 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 tags + + +class TagsTestCase(test_base.TestCase): + + @mock.patch("storyboardclient.v1.tags.TagsManager._list") + def test_tags_list(self, mock_private_list): + tags.TagsManager(mock.MagicMock()).list() + mock_private_list.assert_called_once_with( + "/tags", None) + + @mock.patch("storyboardclient.v1.tags.TagsManager._post") + def test_tags_create(self, mock_private_post): + tags.TagsManager(mock.MagicMock()).create( + tag_name="test_tag") + + mock_private_post.assert_called_once_with( + "/tags", + {"tag_name": "test_tag"}) diff --git a/storyboardclient/v1/client.py b/storyboardclient/v1/client.py index a6a1691..14e891b 100644 --- a/storyboardclient/v1/client.py +++ b/storyboardclient/v1/client.py @@ -18,6 +18,7 @@ from storyboardclient.v1 import project_groups from storyboardclient.v1 import projects from storyboardclient.v1 import stories from storyboardclient.v1 import subscriptions +from storyboardclient.v1 import tags from storyboardclient.v1 import tasks from storyboardclient.v1 import teams from storyboardclient.v1 import users @@ -54,3 +55,4 @@ class Client(base.BaseClient): self.stories = stories.StoriesManager(self) self.users = users.UsersManager(self) self.subscriptions = subscriptions.SubscriptionsManager(self) + self.tags = tags.TagsManager(self) diff --git a/storyboardclient/v1/stories.py b/storyboardclient/v1/stories.py index 04654c3..4f2a52a 100644 --- a/storyboardclient/v1/stories.py +++ b/storyboardclient/v1/stories.py @@ -14,6 +14,7 @@ # limitations under the License. from storyboardclient import base +from storyboardclient.v1 import tags as tags_api from storyboardclient.v1 import tasks from storyboardclient.v1 import timeline @@ -24,10 +25,12 @@ class Story(base.BaseObject): is_bug = None creator_id = None status = None + tags = None tasks = tasks.TasksNestedManager comments = timeline.CommentsNestedManager events = timeline.TimeLineEventsNestedManager + tags_manager = tags_api.TagsNestedManager class StoriesManager(base.BaseManager): diff --git a/storyboardclient/v1/tags.py b/storyboardclient/v1/tags.py new file mode 100644 index 0000000..bc0d071 --- /dev/null +++ b/storyboardclient/v1/tags.py @@ -0,0 +1,37 @@ +# 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 Tag(base.BaseObject): + name = None + + +class TagsManager(base.BaseManager): + url_key = "tags" + resource_class = Tag + + +class TagsNestedManager(base.BaseNestedManager): + parent_url_key = "stories" + url_key = "tags" + resource_class = Tag + + def update(self, tags): + return self._put(self.build_url(), tags) + + def delete(self, tags): + return self.client.delete(self.build_url(), json=tags)