~ubuntu-branches/ubuntu/vivid/python-heatclient/vivid

« back to all changes in this revision

Viewing changes to heatclient/tests/test_resource_types.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 17:41:15 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: package-import@ubuntu.com-20140306174115-ecpzxbyb30tl5i7a
Tags: upstream-0.2.8
ImportĀ upstreamĀ versionĀ 0.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
3
#    not use this file except in compliance with the License. You may obtain
 
4
#    a copy of the License at
 
5
#
 
6
#         http://www.apache.org/licenses/LICENSE-2.0
 
7
#
 
8
#    Unless required by applicable law or agreed to in writing, software
 
9
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
10
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
11
#    License for the specific language governing permissions and limitations
 
12
#    under the License.
 
13
 
 
14
import mock
 
15
import testtools
 
16
 
 
17
from heatclient.v1.resource_types import ResourceTypeManager
 
18
 
 
19
 
 
20
class ResourceTypeManagerTest(testtools.TestCase):
 
21
 
 
22
    def test_list_types(self):
 
23
        manager = ResourceTypeManager(None)
 
24
        manager._list = mock.MagicMock()
 
25
        manager.list()
 
26
        manager._list.assert_called_once_with('/resource_types',
 
27
                                              'resource_types')
 
28
 
 
29
    def test_get(self):
 
30
        resource_type = u'OS::Nova::KeyPair'
 
31
 
 
32
        class FakeAPI(object):
 
33
            """Fake API and ensure request url is correct."""
 
34
            def __init__(self, *args, **kwargs):
 
35
                self.requests = []
 
36
 
 
37
            def json_request(self, *args, **kwargs):
 
38
                self.requests.append(args)
 
39
                return {}, {'attributes': [], 'properties': []}
 
40
 
 
41
        test_api = FakeAPI()
 
42
        manager = ResourceTypeManager(test_api)
 
43
        manager.get(resource_type)
 
44
        expect = ('GET', '/resource_types/OS%3A%3ANova%3A%3AKeyPair')
 
45
        self.assertIn(expect, test_api.requests)