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 13from openstack.tests.unit import base 14 15from openstack.orchestration.v1 import resource 16 17 18FAKE_ID = '32e39358-2422-4ad0-a1b5-dd60696bf564' 19FAKE_NAME = 'test_stack' 20FAKE = { 21 'links': [{ 22 'href': 'http://res_link', 23 'rel': 'self' 24 }, { 25 'href': 'http://stack_link', 26 'rel': 'stack' 27 }], 28 'logical_resource_id': 'the_resource', 29 'name': 'the_resource', 30 'physical_resource_id': '9f38ab5a-37c8-4e40-9702-ce27fc5f6954', 31 'required_by': [], 32 'resource_type': 'OS::Heat::FakeResource', 33 'status': 'CREATE_COMPLETE', 34 'status_reason': 'state changed', 35 'updated_time': '2015-03-09T12:15:57.233772', 36} 37 38 39class TestResource(base.TestCase): 40 41 def test_basic(self): 42 sot = resource.Resource() 43 self.assertEqual('resource', sot.resource_key) 44 self.assertEqual('resources', sot.resources_key) 45 self.assertEqual('/stacks/%(stack_name)s/%(stack_id)s/resources', 46 sot.base_path) 47 self.assertFalse(sot.allow_create) 48 self.assertFalse(sot.allow_retrieve) 49 self.assertFalse(sot.allow_commit) 50 self.assertFalse(sot.allow_delete) 51 self.assertTrue(sot.allow_list) 52 53 def test_make_it(self): 54 sot = resource.Resource(**FAKE) 55 self.assertEqual(FAKE['links'], sot.links) 56 self.assertEqual(FAKE['logical_resource_id'], sot.logical_resource_id) 57 self.assertEqual(FAKE['name'], sot.name) 58 self.assertEqual(FAKE['physical_resource_id'], 59 sot.physical_resource_id) 60 self.assertEqual(FAKE['required_by'], sot.required_by) 61 self.assertEqual(FAKE['resource_type'], sot.resource_type) 62 self.assertEqual(FAKE['status'], sot.status) 63 self.assertEqual(FAKE['status_reason'], sot.status_reason) 64 self.assertEqual(FAKE['updated_time'], sot.updated_at) 65