Define security_group_rules mock in FakeComputev2Client

security_group_rules mock should be defined in
FakeComputev2Client, and used in each test class.

Change-Id: I44bb6379b2c1b6cb277296e08e25dd4d7255c276
This commit is contained in:
Tang Chen 2016-02-04 16:04:06 +08:00
parent 553631a5d4
commit 1740218728
2 changed files with 6 additions and 5 deletions

View File

@ -121,6 +121,9 @@ class FakeComputev2Client(object):
self.security_groups = mock.Mock()
self.security_groups.resource_class = fakes.FakeResource(None, {})
self.security_group_rules = mock.Mock()
self.security_group_rules.resource_class = fakes.FakeResource(None, {})
self.auth_token = kwargs['token']
self.management_url = kwargs['endpoint']

View File

@ -12,7 +12,6 @@
#
import copy
import mock
from openstackclient.compute.v2 import security_group
from openstackclient.tests.compute.v2 import fakes as compute_fakes
@ -106,10 +105,9 @@ class TestSecurityGroupRule(compute_fakes.TestComputev2):
self.secgroups_mock = self.app.client_manager.compute.security_groups
self.secgroups_mock.reset_mock()
self.sg_rules_mock = mock.Mock()
self.sg_rules_mock.resource_class = fakes.FakeResource(None, {})
self.app.client_manager.compute.security_group_rules = \
self.sg_rules_mock
# Get a shortcut compute client security_group_rules mock
self.sg_rules_mock = \
self.app.client_manager.compute.security_group_rules
self.sg_rules_mock.reset_mock()