diff --git a/heat_dashboard/test/tests/content/test_stacks.py b/heat_dashboard/test/tests/content/test_stacks.py index a06ebc6f..27c1642d 100644 --- a/heat_dashboard/test/tests/content/test_stacks.py +++ b/heat_dashboard/test/tests/content/test_stacks.py @@ -14,18 +14,15 @@ import json import re import django -import six - -from django import http - from django.conf import settings from django.core import exceptions from django.test.utils import override_settings from django.urls import reverse from django.utils import html +import mock +import six from heatclient.common import template_format as hc_format -from mox3.mox import IsA from openstack_dashboard import api as dashboard_api from heat_dashboard import api @@ -47,6 +44,8 @@ class MockResource(object): class MappingsTests(test.TestCase): + use_mox = False + def test_mappings(self): def assertMappingUrl(url, resource_type, physical_resource_id): @@ -118,36 +117,18 @@ class MappingsTests(test.TestCase): class StackTests(test.TestCase): + use_mox = False + @override_settings(API_RESULT_PAGE_SIZE=2) - @test.create_stubs({api.heat: ('stacks_list',)}) + @test.create_mocks({api.heat: ('stacks_list',)}) def test_index_paginated(self): stacks = self.stacks.list()[:5] - filters = {} - api.heat.stacks_list(IsA(http.HttpRequest), - marker=None, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([stacks, True, True]) - api.heat.stacks_list(IsA(http.HttpRequest), - marker=None, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([stacks[:2], True, True]) - api.heat.stacks_list(IsA(http.HttpRequest), - marker=stacks[2].id, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([stacks[2:4], True, True]) - api.heat.stacks_list(IsA(http.HttpRequest), - marker=stacks[4].id, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([stacks[4:], True, True]) - self.mox.ReplayAll() + self.mock_stacks_list.side_effect = [ + [stacks, True, True], + [stacks[:2], True, True], + [stacks[2:4], True, True], + [stacks[4:], True, True] + ] url = reverse('horizon:project:stacks:index') res = self.client.get(url) @@ -178,35 +159,16 @@ class StackTests(test.TestCase): 1) @override_settings(API_RESULT_PAGE_SIZE=2) - @test.create_stubs({api.heat: ('stacks_list',)}) + @test.create_mocks({api.heat: ('stacks_list',)}) def test_index_prev_paginated(self): stacks = self.stacks.list()[:3] filters = {} - api.heat.stacks_list(IsA(http.HttpRequest), - marker=None, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([stacks, True, False]) - api.heat.stacks_list(IsA(http.HttpRequest), - marker=None, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([stacks[:2], True, True]) - api.heat.stacks_list(IsA(http.HttpRequest), - marker=stacks[2].id, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([stacks[2:], True, True]) - api.heat.stacks_list(IsA(http.HttpRequest), - marker=stacks[2].id, - paginate=True, - sort_dir='asc', - filters=filters) \ - .AndReturn([stacks[:2], True, True]) - self.mox.ReplayAll() + self.mock_stacks_list.side_effect = [ + [stacks, True, False], + [stacks[:2], True, True], + [stacks[2:], True, True], + [stacks[:2], True, True] + ] url = reverse('horizon:project:stacks:index') res = self.client.get(url) @@ -234,34 +196,24 @@ class StackTests(test.TestCase): # prev back to get first page with 2 pages self.assertEqual(len(res.context['stacks_table'].data), settings.API_RESULT_PAGE_SIZE) + self.mock_stacks_list.assert_has_calls([ + mock.call(test.IsHttpRequest(), marker=None, + paginate=True, sort_dir='desc', filters=filters), + mock.call(test.IsHttpRequest(), marker=None, + paginate=True, sort_dir='desc', filters=filters), + mock.call(test.IsHttpRequest(), marker=stacks[2].id, + paginate=True, sort_dir='desc', filters=filters)]) - @test.create_stubs({api.heat: ('stack_create', 'template_validate'), + @test.create_mocks({api.heat: ('stack_create', 'template_validate'), dashboard_api.neutron: ('network_list_for_tenant', )}) def test_launch_stack(self): template = self.stack_templates.first() stack = self.stacks.first() - - api.heat.template_validate(IsA(http.HttpRequest), - files={}, - template=hc_format.parse(template.data)) \ - .AndReturn(json.loads(template.validate)) - - api.heat.stack_create(IsA(http.HttpRequest), - stack_name=stack.stack_name, - timeout_mins=60, - disable_rollback=True, - template=None, - parameters=IsA(dict), - password='password', - files=None) - dashboard_api.neutron.network_list_for_tenant(IsA(http.HttpRequest), - self.tenant.id) \ - .AndReturn(self.networks.list()) - dashboard_api.neutron.network_list_for_tenant(IsA(http.HttpRequest), - self.tenant.id) \ - .AndReturn(self.networks.list()) - - self.mox.ReplayAll() + self.mock_template_validate.return_value = \ + json.loads(template.validate) + self.mock_stack_create.reutrn_value = None + self.mock_network_list_for_tenant.side_effect = \ + [self.networks.list(), self.networks.list()] url = reverse('horizon:project:stacks:select_template') res = self.client.get(url) @@ -293,37 +245,29 @@ class StackTests(test.TestCase): 'method': forms.CreateStackForm.__name__} res = self.client.post(url, form_data) self.assertRedirectsNoFollow(res, INDEX_URL) + self.mock_template_validate.assert_called_once_with( + test.IsHttpRequest(), files={}, + template=hc_format.parse(template.data)) + self.mock_stack_create.assert_called_once_with( + test.IsHttpRequest(), stack_name=stack.stack_name, + timeout_mins=60, disable_rollback=True, template=None, + parameters=test.IsA(dict), password='password', files=None) + self.mock_network_list_for_tenant.assert_has_calls([ + mock.call(test.IsHttpRequest(), self.tenant.id), + mock.call(test.IsHttpRequest(), self.tenant.id)]) - @test.create_stubs({api.heat: ('stack_create', 'template_validate'), + @test.create_mocks({api.heat: ('stack_create', 'template_validate'), dashboard_api.neutron: ('network_list_for_tenant', )}) def test_launch_stack_with_environment(self): template = self.stack_templates.first() environment = self.stack_environments.first() stack = self.stacks.first() - api.heat.template_validate(IsA(http.HttpRequest), - files={}, - template=hc_format.parse(template.data), - environment=environment.data) \ - .AndReturn(json.loads(template.validate)) - - api.heat.stack_create(IsA(http.HttpRequest), - stack_name=stack.stack_name, - timeout_mins=60, - disable_rollback=True, - template=None, - environment=environment.data, - parameters=IsA(dict), - password='password', - files=None) - dashboard_api.neutron.network_list_for_tenant(IsA(http.HttpRequest), - self.tenant.id) \ - .AndReturn(self.networks.list()) - dashboard_api.neutron.network_list_for_tenant(IsA(http.HttpRequest), - self.tenant.id) \ - .AndReturn(self.networks.list()) - - self.mox.ReplayAll() + self.mock_template_validate.return_value = \ + json.loads(template.validate) + self.mock_stack_create.return_value = None + self.mock_network_list_for_tenant.side_effect = \ + [self.networks.list(), self.networks.list()] url = reverse('horizon:project:stacks:select_template') res = self.client.get(url) @@ -358,8 +302,21 @@ class StackTests(test.TestCase): 'method': forms.CreateStackForm.__name__} res = self.client.post(url, form_data) self.assertRedirectsNoFollow(res, INDEX_URL) + self.mock_template_validate.assert_called_once_with( + test.IsHttpRequest(), files={}, + template=hc_format.parse(template.data), + environment=environment.data) + self.mock_stack_create.assert_called_once_with( + test.IsHttpRequest(), stack_name=stack.stack_name, + timeout_mins=60, disable_rollback=True, + template=None, environment=environment.data, + parameters=test.IsA(dict), password='password', + files=None) + self.mock_network_list_for_tenant.assert_has_calls([ + mock.call(test.IsHttpRequest(), self.tenant.id), + mock.call(test.IsHttpRequest(), self.tenant.id)]) - @test.create_stubs({api.heat: ('template_validate',)}) + @test.create_mocks({api.heat: ('template_validate',)}) def test_launch_stack_with_hidden_parameters(self): template = { 'data': ('heat_template_version: 2013-05-23\n' @@ -387,13 +344,7 @@ class StackTests(test.TestCase): } } } - api.heat.template_validate( - IsA(http.HttpRequest), - files={}, - template=hc_format.parse(template['data']))\ - .AndReturn(template['validate']) - - self.mox.ReplayAll() + self.mock_template_validate.return_value = template['validate'] url = reverse('horizon:project:stacks:select_template') res = self.client.get(url) @@ -425,8 +376,11 @@ class StackTests(test.TestCase): self.assertContains(res, pattern, html=True) self.assertContains(res, secret, html=True) + self.mock_template_validate.assert_called_once_with( + test.IsHttpRequest(), files={}, + template=hc_format.parse(template['data'])) - @test.create_stubs({api.heat: ('template_validate',)}) + @test.create_mocks({api.heat: ('template_validate',)}) def test_launch_stack_with_parameter_group(self): template = { 'data': ('heat_template_version: 2013-05-23\n' @@ -475,13 +429,8 @@ class StackTests(test.TestCase): ] } } - api.heat.template_validate( - IsA(http.HttpRequest), - files={}, - template=hc_format.parse(template['data'])).\ - AndReturn(template['validate']) - - self.mox.ReplayAll() + self.mock_template_validate.return_value = \ + template['validate'] url = reverse('horizon:project:stacks:select_template') res = self.client.get(url) @@ -498,7 +447,7 @@ class StackTests(test.TestCase): flags=re.DOTALL) self.assertRegexpMatches(res.content.decode('utf-8'), regex) - @test.create_stubs({api.heat: ('stack_create', 'template_validate')}) + @test.create_mocks({api.heat: ('stack_create', 'template_validate')}) def test_launch_stack_parameter_types(self): template = { 'data': ('heat_template_version: 2013-05-23\n' @@ -551,26 +500,9 @@ class StackTests(test.TestCase): } stack = self.stacks.first() - api.heat.template_validate( - IsA(http.HttpRequest), - files={}, - template=hc_format.parse(template['data']))\ - .AndReturn(template['validate']) - - api.heat.stack_create(IsA(http.HttpRequest), - stack_name=stack.stack_name, - timeout_mins=60, - disable_rollback=True, - template=hc_format.parse(template['data']), - parameters={'param1': 'some string', - 'param2': 42, - 'param3': '{"key": "value"}', - 'param4': 'a,b,c', - 'param5': True}, - password='password', - files={}) - - self.mox.ReplayAll() + self.mock_template_validate.return_value = \ + template['validate'] + self.mock_stack_create.return_value = None url = reverse('horizon:project:stacks:select_template') res = self.client.get(url) @@ -628,33 +560,33 @@ class StackTests(test.TestCase): 'method': forms.CreateStackForm.__name__} res = self.client.post(url, form_data) self.assertRedirectsNoFollow(res, INDEX_URL) + self.mock_template_validate.assert_called_once_with( + test.IsHttpRequest(), files={}, + template=hc_format.parse(template['data'])) + self.mock_stack_create.assert_called_once_with( + test.IsHttpRequest(), stack_name=stack.stack_name, + timeout_mins=60, disable_rollback=True, + template=hc_format.parse(template['data']), + parameters={'param1': 'some string', + 'param2': 42, + 'param3': '{"key": "value"}', + 'param4': 'a,b,c', + 'param5': True}, + password='password', files={}) - @test.create_stubs({api.heat: ('stack_update', 'stack_get', 'template_get', + @test.create_mocks({api.heat: ('stack_update', 'stack_get', 'template_get', 'template_validate'), dashboard_api.neutron: ('network_list_for_tenant', )}) def test_edit_stack_template(self): template = self.stack_templates.first() stack = self.stacks.first() - # GET to template form - api.heat.stack_get(IsA(http.HttpRequest), - stack.id).AndReturn(stack) - # POST template form, validation - api.heat.template_validate(IsA(http.HttpRequest), - files={}, - template=hc_format.parse(template.data)) \ - .AndReturn(json.loads(template.validate)) - - # GET to edit form - api.heat.stack_get(IsA(http.HttpRequest), - stack.id).AndReturn(stack) - api.heat.template_get(IsA(http.HttpRequest), - stack.id) \ - .AndReturn(json.loads(template.validate)) - - # POST to edit form - api.heat.stack_get(IsA(http.HttpRequest), - stack.id).AndReturn(stack) + self.mock_stack_get.return_value = stack + self.mock_template_validate.return_value = \ + json.loads(template.validate) + self.mock_stack_get.reutrn_value = stack + self.mock_template_get.return_value = \ + json.loads(template.validate) fields = { 'stack_name': stack.stack_name, @@ -662,17 +594,12 @@ class StackTests(test.TestCase): 'timeout_mins': 61, 'password': 'password', 'template': None, - 'parameters': IsA(dict), + 'parameters': test.IsA(dict), 'files': None } - api.heat.stack_update(IsA(http.HttpRequest), - stack_id=stack.id, - **fields) - dashboard_api.neutron.network_list_for_tenant(IsA(http.HttpRequest), - self.tenant.id) \ - .AndReturn(self.networks.list()) - - self.mox.ReplayAll() + self.mock_stack_update.return_value = None + self.mock_network_list_for_tenant.return_value = \ + self.networks.list() url = reverse('horizon:project:stacks:change_template', args=[stack.id]) @@ -705,6 +632,16 @@ class StackTests(test.TestCase): 'method': forms.EditStackForm.__name__} res = self.client.post(url, form_data) self.assertRedirectsNoFollow(res, INDEX_URL) + self.mock_template_validate.assert_called_once_with( + test.IsHttpRequest(), files={}, + template=hc_format.parse(template.data)) + self.mock_template_get.assert_called_once_with( + test.IsHttpRequest(), stack.id) + self.mock_stack_update.assert_called_once_with( + test.IsHttpRequest(), stack_id=stack.id, + **fields) + self.mock_network_list_for_tenant.assert_called_once_with( + test.IsHttpRequest(), self.tenant.id) def test_launch_stack_form_invalid_name_digit(self): self._test_launch_stack_invalid_name('2_StartWithDigit') @@ -715,12 +652,10 @@ class StackTests(test.TestCase): def test_launch_stack_form_invalid_name_point(self): self._test_launch_stack_invalid_name('.StartWithPoint') - @test.create_stubs({dashboard_api.neutron: ('network_list_for_tenant', )}) + @test.create_mocks({dashboard_api.neutron: ('network_list_for_tenant', )}) def _test_launch_stack_invalid_name(self, name): - dashboard_api.neutron.network_list_for_tenant(IsA(http.HttpRequest), - self.tenant.id) \ - .AndReturn(self.networks.list()) - self.mox.ReplayAll() + self.mock_network_list_for_tenant.return_value = \ + self.networks.list() template = self.stack_templates.first() url = reverse('horizon:project:stacks:launch') @@ -748,58 +683,56 @@ class StackTests(test.TestCase): self.assertFormErrors(res, 1) self.assertFormError(res, "form", 'stack_name', error) - def _test_stack_action(self, action): + @test.create_mocks({api.heat: ('stacks_list', 'action_check',)}) + def test_check_stack(self): stack = self.stacks.first() - filters = {} - api.heat.stacks_list(IsA(http.HttpRequest), - marker=None, - paginate=True, - sort_dir='desc', - filters=filters) \ - .AndReturn([self.stacks.list(), True, True]) - getattr(api.heat, 'action_%s' % action)(IsA(http.HttpRequest), - stack.id).AndReturn(stack) + self.mock_stacks_list.return_value = \ + [self.stacks.list(), True, True] + self.mock_action_check.return_value = stack - self.mox.ReplayAll() - - form_data = {"action": "stacks__%s__%s" % (action, stack.id)} + form_data = {"action": "stacks__check__%s" % stack.id} res = self.client.post(INDEX_URL, form_data) self.assertNoFormErrors(res) self.assertRedirectsNoFollow(res, INDEX_URL) - @test.create_stubs({api.heat: ('stacks_list', 'action_check',)}) - def test_check_stack(self): - self._test_stack_action('check') - - @test.create_stubs({api.heat: ('stacks_list', 'action_suspend',)}) + @test.create_mocks({api.heat: ('stacks_list', 'action_suspend',)}) def test_suspend_stack(self): - self._test_stack_action('suspend') + stack = self.stacks.first() - @test.create_stubs({api.heat: ('stacks_list', 'action_resume',)}) + self.mock_stacks_list.return_value = \ + [self.stacks.list(), True, True] + self.mock_action_suspend.return_value = stack + + form_data = {"action": "stacks__suspend__%s" % stack.id} + res = self.client.post(INDEX_URL, form_data) + + self.assertNoFormErrors(res) + self.assertRedirectsNoFollow(res, INDEX_URL) + + @test.create_mocks({api.heat: ('stacks_list', 'action_resume',)}) def test_resume_stack(self): - self._test_stack_action('resume') + stack = self.stacks.first() - @test.create_stubs({api.heat: ('stack_preview', 'template_validate')}) + self.mock_stacks_list.return_value = \ + [self.stacks.list(), True, True] + self.mock_action_resume.return_value = stack + + form_data = {"action": "stacks__resume__%s" % stack.id} + res = self.client.post(INDEX_URL, form_data) + + self.assertNoFormErrors(res) + self.assertRedirectsNoFollow(res, INDEX_URL) + + @test.create_mocks({api.heat: ('stack_preview', 'template_validate')}) def test_preview_stack(self): template = self.stack_templates.first() stack = self.stacks.first() - api.heat.template_validate(IsA(http.HttpRequest), - files={}, - template=hc_format.parse(template.data)) \ - .AndReturn(json.loads(template.validate)) - - api.heat.stack_preview(IsA(http.HttpRequest), - stack_name=stack.stack_name, - timeout_mins=60, - disable_rollback=True, - template=None, - parameters=IsA(dict), - files=None).AndReturn(stack) - - self.mox.ReplayAll() + self.mock_template_validate.return_value = \ + json.loads(template.validate) + self.mock_stack_preview.return_value = stack url = reverse('horizon:project:stacks:preview_template') res = self.client.get(url) @@ -830,19 +763,19 @@ class StackTests(test.TestCase): self.assertTemplateUsed(res, 'project/stacks/preview_details.html') self.assertEqual(res.context['stack_preview']['stack_name'], stack.stack_name) + self.mock_template_validate.assert_called_once_with( + test.IsHttpRequest(), files={}, + template=hc_format.parse(template.data)) - @test.create_stubs({api.heat: ('stack_get', 'template_get', + @test.create_mocks({api.heat: ('stack_get', 'template_get', 'resources_list')}) def test_detail_stack_topology(self): stack = self.stacks.first() template = self.stack_templates.first() - api.heat.stack_get(IsA(http.HttpRequest), stack.id) \ - .MultipleTimes().AndReturn(stack) - api.heat.template_get(IsA(http.HttpRequest), stack.id) \ - .AndReturn(json.loads(template.validate)) - api.heat.resources_list(IsA(http.HttpRequest), stack.stack_name) \ - .AndReturn([]) - self.mox.ReplayAll() + self.mock_stack_get.return_value = stack + self.mock_template_get.return_value = \ + json.loads(template.validate) + self.mock_resources_list.return_value = [] url = '?'.join([reverse(DETAIL_URL, args=[stack.id]), '='.join(['tab', 'stack_details__stack_topology'])]) @@ -855,23 +788,20 @@ class StackTests(test.TestCase): self.assertIn('info_box', d3_data) self.assertIn('stack-green.svg', d3_data) self.assertIn('Create Complete', d3_data) + self.mock_template_get.assert_called_once_with( + test.IsHttpRequest(), stack.id) + self.mock_resources_list.assert_called_once_with( + test.IsHttpRequest(), stack.stack_name) - # @test.create_stubs({api.heat: ('stack_get', 'template_get'), - # project_api: ('d3_data',)}) - @test.create_stubs({api.heat: ('stack_get', 'template_get', + @test.create_mocks({api.heat: ('stack_get', 'template_get', 'resources_list')}) def test_detail_stack_overview(self): stack = self.stacks.first() template = self.stack_templates.first() - api.heat.stack_get(IsA(http.HttpRequest), stack.id) \ - .MultipleTimes().AndReturn(stack) - api.heat.resources_list(IsA(http.HttpRequest), stack.id) \ - .MultipleTimes().AndReturn([]) - api.heat.template_get(IsA(http.HttpRequest), stack.id) \ - .AndReturn(json.loads(template.validate)) - # project_api.d3_data(IsA(http.HttpRequest), stack_id=stack.id) \ - # .AndReturn(json.dumps({"nodes": [], "stack": {}})) - self.mox.ReplayAll() + self.mock_stack_get.return_value = stack + self.mock_resources_list.return_value = [] + self.mock_template_get.return_value = \ + json.loads(template.validate) url = '?'.join([reverse(DETAIL_URL, args=[stack.id]), '='.join(['tab', 'stack_details__stack_overview'])]) @@ -881,28 +811,18 @@ class StackTests(test.TestCase): self.assertEqual(tab.template_name, 'project/stacks/_detail_overview.html') self.assertEqual(stack.stack_name, overview_data.stack_name) + self.mock_template_get.assert_called_once_with( + test.IsHttpRequest(), stack.id) - # @test.create_stubs({api.heat: ('stack_get', - # 'template_get', 'resources_list'), - # project_api: ('d3_data',)}) - @test.create_stubs({api.heat: ('stack_get', 'template_get', + @test.create_mocks({api.heat: ('stack_get', 'template_get', 'resources_list')}) def test_detail_stack_resources(self): stack = self.stacks.first() template = self.stack_templates.first() - api.heat.stack_get(IsA(http.HttpRequest), stack.id) \ - .MultipleTimes().AndReturn(stack) - api.heat.resources_list(IsA(http.HttpRequest), stack.id) \ - .MultipleTimes().AndReturn([]) - api.heat.template_get(IsA(http.HttpRequest), stack.id) \ - .AndReturn(json.loads(template.validate)) - - # Needs to move into JSONView test - # because this part will be called from Ajax - # project_api.d3_data(IsA(http.HttpRequest), stack_id=stack.id) \ - # .AndReturn(json.dumps({"nodes": [], "stack": {}})) - - self.mox.ReplayAll() + self.mock_stack_get.return_value = stack + self.mock_resources_list.return_value = [] + self.mock_template_get.return_value = \ + json.loads(template.validate) url = '?'.join([reverse(DETAIL_URL, args=[stack.id]), '='.join(['tab', 'stack_details__resource_overview'])]) @@ -911,15 +831,13 @@ class StackTests(test.TestCase): self.assertEqual(tab.template_name, 'project/stacks/_detail_resources.html') - @test.create_stubs({api.heat: ('stack_get', 'template_get')}) + @test.create_mocks({api.heat: ('stack_get', 'template_get')}) def test_detail_stack_template(self): stack = self.stacks.first() template = self.stack_templates.first() - api.heat.stack_get(IsA(http.HttpRequest), stack.id) \ - .AndReturn(stack) - api.heat.template_get(IsA(http.HttpRequest), stack.id) \ - .AndReturn(json.loads(template.validate)) - self.mox.ReplayAll() + self.mock_stack_get.return_value = stack + self.mock_template_get.return_value = \ + json.loads(template.validate) url = '?'.join([reverse(DETAIL_URL, args=[stack.id]), '='.join(['tab', 'stack_details__stack_template'])]) @@ -930,19 +848,18 @@ class StackTests(test.TestCase): 'project/stacks/_stack_template.html') self.assertIn(json.loads(template.validate)['Description'], template_data) + self.mock_stack_get.assert_called_once_with( + test.IsHttpRequest(), stack.id) + self.mock_template_get.assert_called_once_with( + test.IsHttpRequest(), stack.id) - @test.create_stubs({api.heat: ('resource_get', 'resource_metadata_get')}) + @test.create_mocks({api.heat: ('resource_get', 'resource_metadata_get')}) def test_resource_view(self): stack = self.stacks.first() resource = self.heat_resources.first() metadata = {} - api.heat.resource_get( - IsA(http.HttpRequest), stack.id, resource.resource_name) \ - .AndReturn(resource) - api.heat.resource_metadata_get( - IsA(http.HttpRequest), stack.id, resource.resource_name) \ - .AndReturn(metadata) - self.mox.ReplayAll() + self.mock_resource_get.return_value = resource + self.mock_resource_metadata_get.return_value = metadata url = reverse('horizon:project:stacks:resource', args=[stack.id, resource.resource_name]) @@ -951,10 +868,16 @@ class StackTests(test.TestCase): self.assertTemplateUsed(res, 'project/stacks/_resource_overview.html') self.assertEqual(res.context['resource'].logical_resource_id, resource.logical_resource_id) + self.mock_resource_get.assert_called_once_with( + test.IsHttpRequest(), stack.id, resource.resource_name) + self.mock_resource_get.assert_called_once_with( + test.IsHttpRequest(), stack.id, resource.resource_name) class TemplateFormTests(test.TestCase): + use_mox = False + class SimpleFile(object): def __init__(self, name, data): self.name = name