make tests work

This commit is contained in:
Christopher O'Brien 2019-10-28 07:42:40 -04:00 committed by Tomas Kopecek
parent 0e3e9380e9
commit 52088adbb1
4 changed files with 7 additions and 6 deletions

View file

@ -129,12 +129,13 @@ class TestAddGroup(unittest.TestCase):
# Run it and check immediate output
rv = handle_add_group(options, session, arguments)
actual = stdout.getvalue()
expected = 'This action requires admin privileges\n'
expected = 'This action requires tag or admin privileges\n'
self.assertMultiLineEqual(actual, expected)
# Finally, assert that things were called as we expected.
activate_session_mock.assert_called_once_with(session, options)
session.hasPerm.assert_called_once_with('admin')
session.hasPerm.assert_has_calls([mock.call('admin'),
mock.call('tag')])
session.getTag.assert_not_called()
session.getTagGroups.assert_not_called()
session.groupListAdd.assert_not_called()

View file

@ -44,7 +44,7 @@ class TestAddTag(utils.CliTestCase):
activate_session=None)
# Case 2. not admin account
expected = "This action requires admin privileges\n"
expected = "This action requires tag or admin privileges\n"
session.hasPerm.return_value = None
handle_add_tag(options, session, ['test-tag'])
self.assert_console_message(stdout, expected)

View file

@ -123,6 +123,6 @@ class TestBlockGroup(utils.CliTestCase):
session.hasPerm.return_value = False
rv = handle_block_group(options, session, ['tag', 'grp'])
self.assert_console_message(
stdout, 'This action requires admin privileges\n')
stdout, 'This action requires tag or admin privileges\n')
self.assertEqual(rv, 1)
activate_session_mock.assert_called_with(session, options)

View file

@ -59,10 +59,10 @@ clone-tag will create the destination tag if it does not already exist
self.session,
args,
stderr=self.format_error_message(
"This action requires admin privileges"),
"This action requires tag or admin privileges"),
activate_session=None)
self.activate_session.assert_called_once()
self.session.hasPerm.assert_called_once_with('admin')
self.session.hasPerm.assert_has_calls([call('admin'), call('tag')])
def test_handle_clone_tag_same_tag(self):
args = ['src-tag', 'src-tag']