Added subscription events controller

Added SubscriptionEvent object and manager.
Added tests.

Change-Id: I24e8edf21fbc5724487e1ac1670f75509d4608a4
This commit is contained in:
Aleksey Ripinen 2015-03-24 16:45:39 +03:00
parent d8e4f3ced3
commit c58a089d4c
3 changed files with 79 additions and 0 deletions

View File

@ -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")

View File

@ -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)

View File

@ -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