Merge pull request #37158 from tchaikov/wip-no-more-assertDictContainsSubset

mgr/dashboard: replace assertDictContainsSubset() with assertLessEqual()

Reviewed-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
Kefu Chai 2020-09-18 15:18:31 +08:00 committed by GitHub
commit 989af0b7cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -389,7 +389,7 @@ class AccessControlTest(unittest.TestCase, CLICommandTestMixin):
uroles.sort()
user = self.exec_cmd('ac-user-add-roles', username=username,
roles=[role])
self.assertDictContainsSubset({'roles': uroles}, user)
self.assertLessEqual(uroles, user['roles'])
self.validate_persistent_user(username, uroles)
self.assertGreaterEqual(user['lastUpdate'], user_orig['lastUpdate'])
@ -397,8 +397,8 @@ class AccessControlTest(unittest.TestCase, CLICommandTestMixin):
user_orig = self.test_create_user()
user = self.exec_cmd('ac-user-add-roles', username="admin",
roles=['pool-manager', 'block-manager'])
self.assertDictContainsSubset(
{'roles': ['block-manager', 'pool-manager']}, user)
self.assertLessEqual(['block-manager', 'pool-manager'],
user['roles'])
self.validate_persistent_user('admin', ['block-manager',
'pool-manager'])
self.assertGreaterEqual(user['lastUpdate'], user_orig['lastUpdate'])
@ -425,14 +425,13 @@ class AccessControlTest(unittest.TestCase, CLICommandTestMixin):
user_orig = self.test_create_user()
user = self.exec_cmd('ac-user-add-roles', username="admin",
roles=['pool-manager'])
self.assertDictContainsSubset(
{'roles': ['pool-manager']}, user)
self.assertLessEqual(['pool-manager'], user['roles'])
self.validate_persistent_user('admin', ['pool-manager'])
self.assertGreaterEqual(user['lastUpdate'], user_orig['lastUpdate'])
user2 = self.exec_cmd('ac-user-set-roles', username="admin",
roles=['rgw-manager', 'block-manager'])
self.assertDictContainsSubset(
{'roles': ['block-manager', 'rgw-manager']}, user2)
self.assertLessEqual(['block-manager', 'rgw-manager'],
user2['roles'])
self.validate_persistent_user('admin', ['block-manager',
'rgw-manager'])
self.assertGreaterEqual(user2['lastUpdate'], user['lastUpdate'])
@ -459,8 +458,7 @@ class AccessControlTest(unittest.TestCase, CLICommandTestMixin):
self.test_add_user_roles()
user = self.exec_cmd('ac-user-del-roles', username="admin",
roles=['pool-manager'])
self.assertDictContainsSubset(
{'roles': ['block-manager']}, user)
self.assertLessEqual(['block-manager'], user['roles'])
self.validate_persistent_user('admin', ['block-manager'])
def test_del_user_roles_not_existent_user(self):