Drop mox from HeatRestTestCase

Dropped mox3 from HeatRestTestCase, apart of the
community mox3 goal.

Change-Id: Ic161dfdbcb39c29be3980063ed547c6105b60d9a
Depends-On: Ibf41998cb154c5170e8038f5b2708c928b68b8b4
Signed-off-by: Charles Short <zulcss@gmail.com>
This commit is contained in:
Charles Short
2018-04-24 09:26:29 -04:00
committed by kaz_shinohara
parent 77eb14f6a6
commit 5eeb7feef5
3 changed files with 10 additions and 10 deletions

View File

@@ -12,14 +12,12 @@
# under the License. # under the License.
# Default to Horizons test settings to avoid any missing keys # Default to Horizons test settings to avoid any missing keys
import heat_dashboard.enabled
import openstack_dashboard.enabled
import openstack_dashboard.enabled # noqa: F811 import openstack_dashboard.enabled # noqa: F811
from openstack_dashboard.test.settings import * # noqa: F403,H303 from openstack_dashboard.test.settings import * # noqa: F403,H303
from openstack_dashboard.utils import settings from openstack_dashboard.utils import settings
import heat_dashboard.enabled
# pop these keys to avoid log warnings about deprecation # pop these keys to avoid log warnings about deprecation
# update_dashboards will populate them anyway # update_dashboards will populate them anyway

View File

@@ -38,32 +38,33 @@ class HeatRestTestCase(test.TestCase):
# Services # Services
# #
@test.create_stubs({api.base: ('is_service_enabled',)}) @test.create_mocks({api.base: ('is_service_enabled',)})
@mock.patch.object(heat.api, 'heat') @mock.patch.object(heat.api, 'heat')
def test_services_get(self, hc): def test_services_get(self, hc):
request = self.mock_rest_request(GET={}) request = self.mock_rest_request(GET={})
api.base.is_service_enabled(request, 'orchestration').AndReturn(True) self.mock_is_service_enabled.return_value = True
hc.service_list.return_value = [ hc.service_list.return_value = [
mock.Mock(**{'to_dict.return_value': {'id': '1'}}), mock.Mock(**{'to_dict.return_value': {'id': '1'}}),
mock.Mock(**{'to_dict.return_value': {'id': '2'}}) mock.Mock(**{'to_dict.return_value': {'id': '2'}})
] ]
self.mox.ReplayAll()
response = heat.Services().get(request) response = heat.Services().get(request)
self.assertStatusCode(response, 200) self.assertStatusCode(response, 200)
self.assertEqual(response.content.decode('utf-8'), self.assertEqual(response.content.decode('utf-8'),
'{"items": [{"id": "1"}, {"id": "2"}]}') '{"items": [{"id": "1"}, {"id": "2"}]}')
hc.service_list.assert_called_once_with(request) hc.service_list.assert_called_once_with(request)
self.mock_is_service_enabled.assert_called_once_with(
request, 'orchestration')
@test.create_stubs({api.base: ('is_service_enabled',)}) @test.create_mocks({api.base: ('is_service_enabled',)})
def test_services_get_disabled(self): def test_services_get_disabled(self):
request = self.mock_rest_request(GET={}) request = self.mock_rest_request(GET={})
api.base.is_service_enabled(request, 'orchestration').AndReturn(False) self.mock_is_service_enabled.return_value = False
self.mox.ReplayAll()
response = heat.Services().get(request) response = heat.Services().get(request)
self.assertStatusCode(response, 501) self.assertStatusCode(response, 501)
self.mock_is_service_enabled.assert_called_once_with(
request, 'orchestration')

View File

@@ -21,6 +21,7 @@ from horizon import exceptions
class HeatApiTests(test.APITestCase): class HeatApiTests(test.APITestCase):
use_mox = True use_mox = True
def test_stack_list(self): def test_stack_list(self):