Ejemplo n.º 1
0
 def test_success(self, mock_error_convert, mock_target, mock_role, mock_assign):
     mock_target.return_value = "target_el"
     mock_role.return_value = "role_el"
     cmd_acl.assign_role_to_target(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     mock_target.assert_called_once_with(self.cib, "target_id")
     mock_role.assert_called_once_with(self.cib, "role_id")
     mock_assign.assert_called_once_with("target_el", "role_el")
     self.assert_same_cib_pushed()
     self.assertEqual(0, mock_error_convert.call_count)
Ejemplo n.º 2
0
 def test_success(self, mock_error_convert, mock_target, mock_role,
                  mock_assign):
     mock_target.return_value = "target_el"
     mock_role.return_value = "role_el"
     cmd_acl.assign_role_to_target(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     mock_target.assert_called_once_with(self.cib, "target_id")
     mock_role.assert_called_once_with(self.cib, "role_id")
     mock_assign.assert_called_once_with("target_el", "role_el")
     self.assert_same_cib_pushed()
     self.assertEqual(0, mock_error_convert.call_count)
Ejemplo n.º 3
0
 def test_failure(self, mock_error_convert, mock_target, mock_role, mock_assign):
     exception_obj = acl_lib.AclTargetNotFound("target_id")
     mock_target.side_effect = exception_obj
     mock_role.return_value = "role_el"
     self.assert_raises(LibraryError, lambda: cmd_acl.assign_role_to_target(self.mock_env, "role_id", "target_id"))
     self.assert_get_cib_called()
     mock_target.assert_called_once_with(self.cib, "target_id")
     mock_error_convert.assert_called_once_with(exception_obj)
     self.assertEqual(0, mock_assign.call_count)
     self.assert_cib_not_pushed()
Ejemplo n.º 4
0
 def test_failure(self, mock_error_convert, mock_target, mock_role,
                  mock_assign):
     exception_obj = acl_lib.AclTargetNotFound("target_id")
     mock_target.side_effect = exception_obj
     mock_role.return_value = "role_el"
     self.assert_raises(
         LibraryError, lambda: cmd_acl.assign_role_to_target(
             self.mock_env, "role_id", "target_id"))
     self.assert_get_cib_called()
     mock_target.assert_called_once_with(self.cib, "target_id")
     mock_error_convert.assert_called_once_with(exception_obj)
     self.assertEqual(0, mock_assign.call_count)
     self.assert_cib_not_pushed()
Ejemplo n.º 5
0
 def test_success(self, mock_assign, find_target):
     find_target.return_value = "target_el"
     cmd_acl.assign_role_to_target(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     mock_assign.assert_called_once_with(self.cib, "role_id", "target_el")
     self.assert_same_cib_pushed()
Ejemplo n.º 6
0
 def test_success(self, mock_assign, find_target):
     find_target.return_value = "target_el"
     cmd_acl.assign_role_to_target(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     mock_assign.assert_called_once_with(self.cib, "role_id", "target_el")
     self.assert_same_cib_pushed()