Added subscriptions controller
Added subscriptions class and manager. Change-Id: I68ba5d653866dc84ee3489309b966379106c952d
This commit is contained in:
40
storyboardclient/tests/v1/test_subscriptions.py
Normal file
40
storyboardclient/tests/v1/test_subscriptions.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# 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 subscriptions
|
||||||
|
|
||||||
|
|
||||||
|
class SubscriptionsTestCase(test_base.TestCase):
|
||||||
|
|
||||||
|
@mock.patch("storyboardclient.v1.subscriptions.SubscriptionsManager._list")
|
||||||
|
def test_subscriptions_list(self, mock_private_list):
|
||||||
|
subscriptions.SubscriptionsManager(mock.MagicMock()).list()
|
||||||
|
|
||||||
|
mock_private_list.assert_called_once_with(
|
||||||
|
"/subscriptions", None)
|
||||||
|
|
||||||
|
@mock.patch("storyboardclient.v1.subscriptions.SubscriptionsManager._post")
|
||||||
|
def test_subscriptions_create(self, mock_private_post):
|
||||||
|
subscriptions.SubscriptionsManager(mock.MagicMock()).create(
|
||||||
|
target_type="story",
|
||||||
|
target_id="test_story_id")
|
||||||
|
|
||||||
|
mock_private_post.assert_called_once_with(
|
||||||
|
"/subscriptions",
|
||||||
|
{"target_type": "story",
|
||||||
|
"target_id": "test_story_id"})
|
@@ -17,6 +17,7 @@ from storyboardclient import base
|
|||||||
from storyboardclient.v1 import project_groups
|
from storyboardclient.v1 import project_groups
|
||||||
from storyboardclient.v1 import projects
|
from storyboardclient.v1 import projects
|
||||||
from storyboardclient.v1 import stories
|
from storyboardclient.v1 import stories
|
||||||
|
from storyboardclient.v1 import subscriptions
|
||||||
from storyboardclient.v1 import tasks
|
from storyboardclient.v1 import tasks
|
||||||
from storyboardclient.v1 import teams
|
from storyboardclient.v1 import teams
|
||||||
from storyboardclient.v1 import users
|
from storyboardclient.v1 import users
|
||||||
@@ -52,3 +53,4 @@ class Client(base.BaseClient):
|
|||||||
self.project_groups = project_groups.ProjectGroupsManager(self)
|
self.project_groups = project_groups.ProjectGroupsManager(self)
|
||||||
self.stories = stories.StoriesManager(self)
|
self.stories = stories.StoriesManager(self)
|
||||||
self.users = users.UsersManager(self)
|
self.users = users.UsersManager(self)
|
||||||
|
self.subscriptions = subscriptions.SubscriptionsManager(self)
|
||||||
|
27
storyboardclient/v1/subscriptions.py
Normal file
27
storyboardclient/v1/subscriptions.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# 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 Subscription(base.BaseObject):
|
||||||
|
user_id = None
|
||||||
|
target_type = None
|
||||||
|
target_id = None
|
||||||
|
|
||||||
|
|
||||||
|
class SubscriptionsManager(base.BaseManager):
|
||||||
|
url_key = "subscriptions"
|
||||||
|
resource_class = Subscription
|
Reference in New Issue
Block a user