# See the License for the specific language governing permissions and
# limitations under the License.
-__author__ = 'gpetralx'
-
+from __future__ import print_function
+from __future__ import absolute_import
+import os
import unittest
-from experimental_framework import heat_manager
+import logging
+import experimental_framework.common as common
+
+from experimental_framework import heat_manager, APEX_LAKE_ROOT
import mock
+__author__ = 'gpetralx'
+
def get_mock_heat(version, *args, **kwargs):
return MockHeat()
class MockStacks(object):
+
def __init__(self, stacks):
self.stacks = stacks
list_name = list()
for stack in self.stacks:
list_name.append(stack.stack_name)
- print list_name
+ print(list_name)
return self.stacks
def validate(self, template=None):
def create(self, stack_name=None, files=None, template=None,
parameters=None):
- print stack_name
+ print(stack_name)
self.stacks.append(MockStack(stack_name))
class MockStacks_2(object):
+
def __init__(self, stacks):
self.stacks = stacks
class MockStack(object):
+
def __init__(self, stack_name):
self.name = stack_name
class MockHeat(object):
+
def __init__(self):
stacks = [MockStack('stack_1'), MockStack('stack_2')]
self.stacks_list = MockStacks(stacks)
class MockHeat_2(MockHeat):
+
def __init__(self):
stacks = [MockStack('stack_1'), MockStack('stack_2')]
self.stacks_list = MockStacks_2(stacks)
class HeatManagerMock(heat_manager.HeatManager):
+
def init_heat(self):
if self.heat is None:
self.heat = MockHeat()
class HeatManagerMock_2(heat_manager.HeatManager):
+
def init_heat(self):
if self.heat is None:
self.heat = MockHeat_2()
self.heat_manager.check_stack_status('stack_x'))
def test_validate_template_for_success(self):
- template_file = \
- 'tests/data/test_templates/VTC_base_single_vm_wait_1.yaml'
+ template_file = os.path.join(
+ APEX_LAKE_ROOT,
+ 'tests/data/test_templates/VTC_base_single_vm_wait_1.yaml')
with self.assertRaises(ValueError):
self.heat_manager.validate_heat_template(template_file)
pass
def test_delete_stack_for_success_2(self):
+ common.LOG = logging.getLogger()
self.assertFalse(self.heat_manager.delete_stack('stack_1'))
+class ServiceCatalog():
+
+ def url_for(self, service_type):
+ return 'http://heat_url'
+
+
class KeystoneMock(object):
+
@property
def auth_token(self):
return 'token'
+ service_catalog = ServiceCatalog()
+
class TestHeatInit(unittest.TestCase):
+
def setUp(self):
credentials = dict()
credentials['ip_controller'] = '1.1.1.1'
tenant_name='project',
password='password',
auth_url='auth_uri')
- heat_client.assert_called_once_with('1', endpoint='http://heat_url',
+ heat_client.assert_called_once_with('1', endpoint='http://heat_url',
token='token')