Пример #1
0
def test_commnads_pre_yum_rollback(patch_logging, mocker):
    mock = mocker.patch.object(
        commands, 'cluster_maintenance_enable', autospec=True
    )

    exc = TypeError('some error')
    commands._pre_yum_rollback('some-ctx', type(exc), exc, 'some traceback')
    mock.assert_not_called()

    for exc in (
        HAPostUpdateError('some error'),
        ClusterNotHealthyError('some error')
    ):
        mock.reset_mock()
        mock.side_effect = None
        commands._pre_yum_rollback(
            'some-ctx', type(exc), exc, 'some traceback'
        )
        mock.assert_called_once_with()

        mock.reset_mock()
        mock.side_effect = ValueError('some another error')

        with pytest.raises(ClusterMaintenanceEnableError):
            commands._pre_yum_rollback(
                'some-ctx', type(exc), exc, 'some traceback'
            )
        mock.assert_called_once_with()
Пример #2
0
def test_ClusterNotHealthyError_str():
    reason = 'some-reason'

    obj = ClusterNotHealthyError(reason)

    assert str(obj) == "failed to apply Hare post_update logic, reason: {!r}"\
        .format(reason)