From c58a089d4cd027cfa251f7d0318fbf4106e3b596 Mon Sep 17 00:00:00 2001 From: Aleksey Ripinen Date: Tue, 24 Mar 2015 16:45:39 +0300 Subject: [PATCH] Added subscription events controller Added SubscriptionEvent object and manager. Added tests. Change-Id: I24e8edf21fbc5724487e1ac1670f75509d4608a4 --- .../tests/v1/subscription_events.py | 48 +++++++++++++++++++ storyboardclient/v1/client.py | 3 ++ storyboardclient/v1/subscription_events.py | 28 +++++++++++ 3 files changed, 79 insertions(+) create mode 100644 storyboardclient/tests/v1/subscription_events.py create mode 100644 storyboardclient/v1/subscription_events.py diff --git a/storyboardclient/tests/v1/subscription_events.py b/storyboardclient/tests/v1/subscription_events.py new file mode 100644 index 0000000..912e46e --- /dev/null +++ b/storyboardclient/tests/v1/subscription_events.py @@ -0,0 +1,48 @@ +# 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 subscription_events + + +class SubscriptionEventsTestCase(test_base.TestCase): + + @mock.patch("storyboardclient.v1." + "subscription_events.SubscriptionEventsManager._list") + def test_subscription_events_list(self, mock_private_list): + subscription_events.SubscriptionEventsManager(mock.MagicMock()).list() + + mock_private_list.assert_called_once_with( + "/subscription_events", None) + + @mock.patch("storyboardclient.v1." + "subscription_events.SubscriptionEventsManager._get") + def test_subscription_events_get(self, mock_private_get): + subscription_events.SubscriptionEventsManager(mock.MagicMock()).\ + get("test_subscription_event_id") + + mock_private_get.assert_called_once_with( + "/subscription_events/test_subscription_event_id", None) + + @mock.patch("storyboardclient.v1." + "subscription_events.SubscriptionEventsManager._delete") + def test_subscription_events_delete(self, mock_private_delete): + subscription_events.SubscriptionEventsManager(mock.MagicMock()).\ + delete(id="test_subscription_event_id") + + mock_private_delete.assert_called_once_with( + "/subscription_events/test_subscription_event_id") diff --git a/storyboardclient/v1/client.py b/storyboardclient/v1/client.py index 01aaff7..3e5e3d3 100644 --- a/storyboardclient/v1/client.py +++ b/storyboardclient/v1/client.py @@ -19,6 +19,7 @@ from storyboardclient.v1 import milestones from storyboardclient.v1 import project_groups from storyboardclient.v1 import projects from storyboardclient.v1 import stories +from storyboardclient.v1 import subscription_events from storyboardclient.v1 import subscriptions from storyboardclient.v1 import tags from storyboardclient.v1 import tasks @@ -57,6 +58,8 @@ class Client(base.BaseClient): self.project_groups = project_groups.ProjectGroupsManager(self) self.stories = stories.StoriesManager(self) self.users = users.UsersManager(self) + self.subscription_events = \ + subscription_events.SubscriptionEventsManager(self) self.subscriptions = subscriptions.SubscriptionsManager(self) self.tags = tags.TagsManager(self) self.milestones = milestones.MilestonesManager(self) diff --git a/storyboardclient/v1/subscription_events.py b/storyboardclient/v1/subscription_events.py new file mode 100644 index 0000000..1f6805c --- /dev/null +++ b/storyboardclient/v1/subscription_events.py @@ -0,0 +1,28 @@ +# 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 SubscriptionEvent(base.BaseObject): + subscriber_id = None + author_id = None + event_type = None + event_info = None + + +class SubscriptionEventsManager(base.BaseManager): + url_key = "subscription_events" + resource_class = SubscriptionEvent \ No newline at end of file