Merge "tests: Stop setting attributes on class"
This commit is contained in:
commit
4e8be5aa64
openstackclient/tests/unit/identity
@ -53,8 +53,7 @@ class TestCatalogList(TestCatalog):
|
||||
identity_fakes.TOKEN,
|
||||
fake_service=self.service_catalog,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -99,8 +98,7 @@ class TestCatalogList(TestCatalog):
|
||||
identity_fakes.TOKEN,
|
||||
fake_service=service_catalog,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -136,8 +134,7 @@ class TestCatalogShow(TestCatalog):
|
||||
identity_fakes.UNSCOPED_TOKEN,
|
||||
fake_service=self.service_catalog,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = [
|
||||
'compute',
|
||||
|
@ -58,8 +58,7 @@ class TestRole(identity_fakes.TestIdentityv2):
|
||||
identity_fakes.TOKEN,
|
||||
fake_service=self.fake_service,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
|
||||
class TestRoleAdd(TestRole):
|
||||
|
@ -169,7 +169,8 @@ class TestRoleAssignmentList(TestRoleAssignment):
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_role_assignment_list_def_creds(self):
|
||||
auth_ref = self.app.client_manager.auth_ref = mock.Mock()
|
||||
self.app.client_manager.auth_ref = mock.Mock()
|
||||
auth_ref = self.app.client_manager.auth_ref
|
||||
auth_ref.project_id.return_value = identity_fakes.project_id
|
||||
auth_ref.user_id.return_value = identity_fakes.user_id
|
||||
|
||||
|
@ -11,29 +11,17 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from openstackclient.identity.v2_0 import token
|
||||
from openstackclient.tests.unit.identity.v2_0 import fakes as identity_fakes
|
||||
|
||||
|
||||
class TestToken(identity_fakes.TestIdentityv2):
|
||||
fake_user = identity_fakes.FakeUser.create_one_user()
|
||||
fake_project = identity_fakes.FakeProject.create_one_project()
|
||||
|
||||
class TestTokenIssue(identity_fakes.TestIdentityv2):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# Get a shortcut to the Auth Ref Mock
|
||||
self.ar_mock = mock.PropertyMock()
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
|
||||
|
||||
class TestTokenIssue(TestToken):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.fake_user = identity_fakes.FakeUser.create_one_user()
|
||||
self.fake_project = identity_fakes.FakeProject.create_one_project()
|
||||
|
||||
self.cmd = token.IssueToken(self.app, None)
|
||||
|
||||
@ -41,8 +29,7 @@ class TestTokenIssue(TestToken):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.TOKEN,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -67,8 +54,7 @@ class TestTokenIssue(TestToken):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.UNSCOPED_TOKEN,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -91,7 +77,7 @@ class TestTokenIssue(TestToken):
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
|
||||
class TestTokenRevoke(TestToken):
|
||||
class TestTokenRevoke(identity_fakes.TestIdentityv2):
|
||||
TOKEN = 'fob'
|
||||
|
||||
def setUp(self):
|
||||
|
@ -9,7 +9,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from unittest import mock
|
||||
|
||||
@ -72,8 +71,7 @@ class TestCatalogList(TestCatalog):
|
||||
identity_fakes.TOKEN_WITH_PROJECT_ID,
|
||||
fake_service=self.fake_service,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -110,8 +108,7 @@ class TestCatalogShow(TestCatalog):
|
||||
identity_fakes.TOKEN_WITH_PROJECT_ID,
|
||||
fake_service=self.fake_service,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = [
|
||||
'compute',
|
||||
|
@ -11,7 +11,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from unittest import mock
|
||||
from unittest.mock import call
|
||||
@ -914,8 +913,7 @@ class TestProjectList(TestProject):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.TOKEN_WITH_PROJECT_ID,
|
||||
)
|
||||
ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = [
|
||||
'--my-projects',
|
||||
|
@ -708,7 +708,8 @@ class TestRoleAssignmentList(identity_fakes.TestIdentityv3):
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_role_assignment_list_def_creds(self):
|
||||
auth_ref = self.app.client_manager.auth_ref = mock.Mock()
|
||||
self.app.client_manager.auth_ref = mock.Mock()
|
||||
auth_ref = self.app.client_manager.auth_ref
|
||||
auth_ref.project_id.return_value = self.project.id
|
||||
auth_ref.user_id.return_value = self.user.id
|
||||
|
||||
|
@ -11,24 +11,12 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from openstackclient.identity.v3 import token
|
||||
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
|
||||
|
||||
|
||||
class TestToken(identity_fakes.TestIdentityv3):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# Get a shortcut to the Auth Ref Mock
|
||||
self.ar_mock = mock.PropertyMock()
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
|
||||
|
||||
class TestTokenIssue(TestToken):
|
||||
class TestTokenIssue(identity_fakes.TestIdentityv3):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@ -38,8 +26,7 @@ class TestTokenIssue(TestToken):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.TOKEN_WITH_PROJECT_ID,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -64,8 +51,7 @@ class TestTokenIssue(TestToken):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.TOKEN_WITH_DOMAIN_ID,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -90,8 +76,7 @@ class TestTokenIssue(TestToken):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.UNSCOPED_TOKEN,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
self.app.client_manager.auth_ref = auth_ref
|
||||
|
||||
arglist = []
|
||||
verifylist = []
|
||||
@ -114,7 +99,7 @@ class TestTokenIssue(TestToken):
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
|
||||
class TestTokenRevoke(TestToken):
|
||||
class TestTokenRevoke(identity_fakes.TestIdentityv3):
|
||||
TOKEN = 'fob'
|
||||
|
||||
def setUp(self):
|
||||
|
@ -236,7 +236,8 @@ class TestTrustList(TestTrust):
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_trust_list_auth_user(self):
|
||||
auth_ref = self.app.client_manager.auth_ref = mock.Mock()
|
||||
self.app.client_manager.auth_ref = mock.Mock()
|
||||
auth_ref = self.app.client_manager.auth_ref
|
||||
auth_ref.user_id.return_value = identity_fakes.user_id
|
||||
|
||||
arglist = ['--auth-user']
|
||||
|
Loading…
x
Reference in New Issue
Block a user