From 5aceae91da26b5ac7c52a7f11989d4287d30f60d Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Wed, 23 Nov 2016 16:52:15 +0800 Subject: [PATCH] Fix some slowest tests in unit/api Change-Id: I20eda96b6940ea9985b7453c65708e4cf793e59f --- nimble/tests/unit/api/v1/test_instance.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nimble/tests/unit/api/v1/test_instance.py b/nimble/tests/unit/api/v1/test_instance.py index 50f5e6cd..009fa445 100644 --- a/nimble/tests/unit/api/v1/test_instance.py +++ b/nimble/tests/unit/api/v1/test_instance.py @@ -66,13 +66,17 @@ class TestInstanceAuthorization(v1_test.APITestV1): headers = self.gen_headers(self.context) self.post_json('/instances', body, headers=headers, status=201) - def test_instance_get_one_by_owner(self): + @mock.patch('nimble.engine.api.API.get_ironic_node') + def test_instance_get_one_by_owner(self, mock_get_node): + mock_get_node.return_value = {'power_state': 'power on'} # not admin but the owner self.context.project_id = self.instance1.project_id headers = self.gen_headers(self.context, roles="no-admin") self.get_json('/instances/%s' % self.instance1.uuid, headers=headers) - def test_instance_get_one_by_admin(self): + @mock.patch('nimble.engine.api.API.get_ironic_node') + def test_instance_get_one_by_admin(self, mock_get_node): + mock_get_node.return_value = {'power_state': 'power on'} # admin but the owner self.context.project_id = self.instance1.project_id # when the evil tenant is admin, he can do everything.