Debian Codegraph @

heatclient/tests/unit/osc/v1/test_service.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12 #
13
14 from heatclient.osc.v1 import service as osc_service
15 from heatclient.tests.unit.osc.v1 import fakes as orchestration_fakes
16
17
18 class TestServiceList(orchestration_fakes.TestOrchestrationv1):
19 response = {"services": [
20 {
21 "status": "up",
22 "binary": "heat-engine",
23 "report_interval": 60,
24 "engine_id": "9d9242c3-4b9e-45e1-9e74-7615fbf20e5d",
25 "created_at": "2015-02-03T05:55:59.000000",
26 "hostname": "mrkanag",
27 "updated_at": "2015-02-03T05:57:59.000000",
28 "topic": "engine",
29 "host": "engine-1",
30 "deleted_at": 'null',
31 "id": "e1908f44-42f9-483f-b778-bc814072c33d"
32 },
33 {
34 "status": "down",
35 "binary": "heat-engine",
36 "report_interval": 60,
37 "engine_id": "2d2434bf-adb6-4453-9c6b-b22fb8bd2306",
38 "created_at": "2015-02-03T06:03:14.000000",
39 "hostname": "mrkanag",
40 "updated_at": "2015-02-03T06:09:55.000000",
41 "topic": "engine",
42 "host": "engine",
43 "deleted_at": 'null',
44 "id": "582b5657-6db7-48ad-8483-0096350faa21"
45 }
46 ]}
47
48 columns = ['Hostname', 'Binary', 'Engine ID', 'Host',
49 'Topic', 'Updated At', 'Status']
50
51 def setUp(self):
52 super().setUp()
53 self.cmd = osc_service.ListService(self.app, None)
54 self.mock_client = self.app.client_manager.orchestration
55 self.mock_client.services.list.return_value = self.response
56
57 def test_service_list(self):
58 arglist = []
59 parsed_args = self.check_parser(self.cmd, arglist, [])
60 columns, data = self.cmd.take_action(parsed_args)
61 self.mock_client.services.list.assert_called_with()
62 self.assertEqual(self.columns, columns)