# -*- coding: utf-8 -*-
"""Test fixtures for controllers."""


import unittest.mock as mock

import pytest

from cephlcm.common.models import task


def have_mocked(request, *mock_args, **mock_kwargs):
    if len(mock_args) > 1:
        method = mock.patch.object
    else:
        method = mock.patch

    patch = method(*mock_args, **mock_kwargs)
    mocked = patch.start()

    request.addfinalizer(patch.stop)

    return mocked


@pytest.fixture
def task_watch(request):
    return have_mocked(request, task.Task, "watch")


@pytest.fixture
def mainloop_process_task(request):
    return have_mocked(request, "cephlcm.controller.mainloop.process_task")


@pytest.fixture
def mainloop_possible_to_process(request):
    mocked = have_mocked(request,
                         "cephlcm.controller.mainloop.possible_to_process")
    mocked.return_value = True

    return mocked


@pytest.fixture
def mocked_sysexit(request):
    return have_mocked(request, "sys.exit")

e3931af3adcdcdfed3c8214e1ef6e02ff4b7c3c3
<mask token>


@pytest.fixture
def mainloop_process_task(request):
    return have_mocked(request, 'cephlcm.controller.mainloop.process_task')


<mask token>


@pytest.fixture
def mocked_sysexit(request):
    return have_mocked(request, 'sys.exit')

<mask token>


@pytest.fixture
def task_watch(request):
    return have_mocked(request, task.Task, 'watch')


@pytest.fixture
def mainloop_process_task(request):
    return have_mocked(request, 'cephlcm.controller.mainloop.process_task')


@pytest.fixture
def mainloop_possible_to_process(request):
    mocked = have_mocked(request,
        'cephlcm.controller.mainloop.possible_to_process')
    mocked.return_value = True
    return mocked


@pytest.fixture
def mocked_sysexit(request):
    return have_mocked(request, 'sys.exit')

<mask token>


def have_mocked(request, *mock_args, **mock_kwargs):
    if len(mock_args) > 1:
        method = mock.patch.object
    else:
        method = mock.patch
    patch = method(*mock_args, **mock_kwargs)
    mocked = patch.start()
    request.addfinalizer(patch.stop)
    return mocked


@pytest.fixture
def task_watch(request):
    return have_mocked(request, task.Task, 'watch')


@pytest.fixture
def mainloop_process_task(request):
    return have_mocked(request, 'cephlcm.controller.mainloop.process_task')


@pytest.fixture
def mainloop_possible_to_process(request):
    mocked = have_mocked(request,
        'cephlcm.controller.mainloop.possible_to_process')
    mocked.return_value = True
    return mocked


@pytest.fixture
def mocked_sysexit(request):
    return have_mocked(request, 'sys.exit')

<mask token>
import unittest.mock as mock
import pytest
from cephlcm.common.models import task


def have_mocked(request, *mock_args, **mock_kwargs):
    if len(mock_args) > 1:
        method = mock.patch.object
    else:
        method = mock.patch
    patch = method(*mock_args, **mock_kwargs)
    mocked = patch.start()
    request.addfinalizer(patch.stop)
    return mocked


@pytest.fixture
def task_watch(request):
    return have_mocked(request, task.Task, 'watch')


@pytest.fixture
def mainloop_process_task(request):
    return have_mocked(request, 'cephlcm.controller.mainloop.process_task')


@pytest.fixture
def mainloop_possible_to_process(request):
    mocked = have_mocked(request,
        'cephlcm.controller.mainloop.possible_to_process')
    mocked.return_value = True
    return mocked


@pytest.fixture
def mocked_sysexit(request):
    return have_mocked(request, 'sys.exit')

# -*- coding: utf-8 -*-
"""Test fixtures for controllers."""


import unittest.mock as mock

import pytest

from cephlcm.common.models import task


def have_mocked(request, *mock_args, **mock_kwargs):
    if len(mock_args) > 1:
        method = mock.patch.object
    else:
        method = mock.patch

    patch = method(*mock_args, **mock_kwargs)
    mocked = patch.start()

    request.addfinalizer(patch.stop)

    return mocked


@pytest.fixture
def task_watch(request):
    return have_mocked(request, task.Task, "watch")


@pytest.fixture
def mainloop_process_task(request):
    return have_mocked(request, "cephlcm.controller.mainloop.process_task")


@pytest.fixture
def mainloop_possible_to_process(request):
    mocked = have_mocked(request,
                         "cephlcm.controller.mainloop.possible_to_process")
    mocked.return_value = True

    return mocked


@pytest.fixture
def mocked_sysexit(request):
    return have_mocked(request, "sys.exit")
