summaryrefslogtreecommitdiff
path: root/openstack_dashboard/test/api_tests/heat_rest_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/test/api_tests/heat_rest_tests.py')
-rw-r--r--openstack_dashboard/test/api_tests/heat_rest_tests.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/openstack_dashboard/test/api_tests/heat_rest_tests.py b/openstack_dashboard/test/api_tests/heat_rest_tests.py
deleted file mode 100644
index ef5cc0f..0000000
--- a/openstack_dashboard/test/api_tests/heat_rest_tests.py
+++ /dev/null
@@ -1,69 +0,0 @@
1# (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14import json
15
16import mock
17
18from openstack_dashboard import api
19from openstack_dashboard.api.rest import heat
20from openstack_dashboard.test import helpers as test
21
22
23class ValidateRestTestCase(test.TestCase):
24 @mock.patch.object(heat.api, 'heat')
25 def test_validate_post(self, hc):
26 body = '''{"template_url":"http://localhost/template.yaml"}'''
27 request = self.mock_rest_request(body=body)
28 hc.template_validate.return_value = ({'Description': 'foo'})
29 response = heat.Validate().post(request)
30 self.assertStatusCode(response, 200)
31 self.assertEqual(response.json, {"Description": "foo"})
32 kwargs = json.loads(body)
33 hc.template_validate.assert_called_once_with(request, **kwargs)
34
35
36class HeatRestTestCase(test.TestCase):
37 #
38 # Services
39 #
40
41 @test.create_stubs({api.base: ('is_service_enabled',)})
42 @mock.patch.object(heat.api, 'heat')
43 def test_services_get(self, hc):
44 request = self.mock_rest_request(GET={})
45
46 api.base.is_service_enabled(request, 'orchestration').AndReturn(True)
47
48 hc.service_list.return_value = [
49 mock.Mock(**{'to_dict.return_value': {'id': '1'}}),
50 mock.Mock(**{'to_dict.return_value': {'id': '2'}})
51 ]
52 self.mox.ReplayAll()
53
54 response = heat.Services().get(request)
55 self.assertStatusCode(response, 200)
56 self.assertEqual(response.content.decode('utf-8'),
57 '{"items": [{"id": "1"}, {"id": "2"}]}')
58 hc.service_list.assert_called_once_with(request)
59
60 @test.create_stubs({api.base: ('is_service_enabled',)})
61 def test_services_get_disabled(self):
62 request = self.mock_rest_request(GET={})
63
64 api.base.is_service_enabled(request, 'orchestration').AndReturn(False)
65
66 self.mox.ReplayAll()
67
68 response = heat.Services().get(request)
69 self.assertStatusCode(response, 501)