Esempio n. 1
0
 def test_success(self, mock_error_convert, mock_group, mock_role, mock_assign):
     mock_group.return_value = "group_el"
     mock_role.return_value = "role_el"
     cmd_acl.assign_role_to_group(self.mock_env, "role_id", "group_id")
     self.assert_get_cib_called()
     mock_group.assert_called_once_with(self.cib, "group_id")
     mock_role.assert_called_once_with(self.cib, "role_id")
     mock_assign.assert_called_once_with("group_el", "role_el")
     self.assert_same_cib_pushed()
     self.assertEqual(0, mock_error_convert.call_count)
Esempio n. 2
0
 def test_success(self, mock_error_convert, mock_group, mock_role,
                  mock_assign):
     mock_group.return_value = "group_el"
     mock_role.return_value = "role_el"
     cmd_acl.assign_role_to_group(self.mock_env, "role_id", "group_id")
     self.assert_get_cib_called()
     mock_group.assert_called_once_with(self.cib, "group_id")
     mock_role.assert_called_once_with(self.cib, "role_id")
     mock_assign.assert_called_once_with("group_el", "role_el")
     self.assert_same_cib_pushed()
     self.assertEqual(0, mock_error_convert.call_count)
Esempio n. 3
0
 def test_failure(self, mock_error_convert, mock_group, mock_role, mock_assign):
     exception_obj = acl_lib.AclGroupNotFound("group_id")
     mock_group.side_effect = exception_obj
     mock_role.return_value = "role_el"
     self.assert_raises(LibraryError, lambda: cmd_acl.assign_role_to_group(self.mock_env, "role_id", "group_id"))
     self.assert_get_cib_called()
     mock_group.assert_called_once_with(self.cib, "group_id")
     mock_error_convert.assert_called_once_with(exception_obj)
     self.assertEqual(0, mock_assign.call_count)
     self.assert_cib_not_pushed()
Esempio n. 4
0
 def test_failure(self, mock_error_convert, mock_group, mock_role,
                  mock_assign):
     exception_obj = acl_lib.AclGroupNotFound("group_id")
     mock_group.side_effect = exception_obj
     mock_role.return_value = "role_el"
     self.assert_raises(
         LibraryError, lambda: cmd_acl.assign_role_to_group(
             self.mock_env, "role_id", "group_id"))
     self.assert_get_cib_called()
     mock_group.assert_called_once_with(self.cib, "group_id")
     mock_error_convert.assert_called_once_with(exception_obj)
     self.assertEqual(0, mock_assign.call_count)
     self.assert_cib_not_pushed()
Esempio n. 5
0
 def test_success(self, mock_assign, find_group):
     find_group.return_value = "group_el"
     cmd_acl.assign_role_to_group(self.mock_env, "role_id", "group_id")
     self.assert_get_cib_called()
     mock_assign.assert_called_once_with(self.cib, "role_id", "group_el")
     self.assert_same_cib_pushed()
Esempio n. 6
0
 def test_success(self, mock_assign, find_group):
     find_group.return_value = "group_el"
     cmd_acl.assign_role_to_group(self.mock_env, "role_id", "group_id")
     self.assert_get_cib_called()
     mock_assign.assert_called_once_with(self.cib, "role_id", "group_el")
     self.assert_same_cib_pushed()