summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzxgao <zxgao@fiberhome.com>2018-12-19 16:17:47 +0800
committerzxgao <zxgao@fiberhome.com>2018-12-19 16:17:47 +0800
commit55af2ffa8db79210ec95a57f4409f446dcdf2a96 (patch)
tree55730986e1ef92a648791aabf389b22f6662ab02
parentf2617cde8a829f0666bf212fea19dcb1b90d0a58 (diff)
Add test case for nodes api.HEADmaster
Notes
Notes (review): Code-Review+2: Tao Li <litao3721@126.com> Code-Review+2: wanghao <sxmatch1986@gmail.com> Workflow+1: wanghao <sxmatch1986@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 19 Dec 2018 09:36:21 +0000 Reviewed-on: https://review.openstack.org/626112 Project: openstack/mogan Branch: refs/heads/master
-rw-r--r--mogan/tests/unit/api/v1/test_node.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/mogan/tests/unit/api/v1/test_node.py b/mogan/tests/unit/api/v1/test_node.py
new file mode 100644
index 0000000..3892661
--- /dev/null
+++ b/mogan/tests/unit/api/v1/test_node.py
@@ -0,0 +1,30 @@
1#
2# Copyright 2018 Fiberhome
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15import mock
16
17from mogan.tests.functional.api import v1 as v1_test
18
19
20class TestNodeAuthorization(v1_test.APITestV1):
21
22 def setUp(self):
23 super(TestNodeAuthorization, self).setUp()
24
25 @mock.patch('mogan.engine.api.API.list_compute_nodes')
26 def test_get_nodes_by_admin(self, mock_list):
27 mock_list.return_value = {'nodes': ['node1', 'node2']}
28 headers = self.gen_headers(self.context, roles="admin")
29 resp = self.get_json('/nodes', headers=headers)
30 self.assertItemsEqual(['node1', 'node2'], resp['nodes'])