import pytest
from mock_alchemy.mocking import UnifiedAlchemyMagicMock
from pyramid.config import Configurator
from pyramid.testing import DummyRequest, setUp, tearDown
from unittest.mock import MagicMock, patch

from unittest import mock

from workspaces.notification.schema import NotificationTemplate
from workspaces.notification.services.notification_info import NotificationInfo
pytest_plugins = ["testing.utils.conftest"]


@pytest.fixture(scope="module")
def test_config() -> Configurator:
    """
    Returns a dummy Configurator object for testing
    :return: Dummy Configurator
    """
    request = DummyRequest()
    config = setUp(request=request)
    config.add_request_method(
        lambda lookup: MagicMock(),
        "notification_info",
        reify=True
    )
    yield config
    tearDown()


@pytest.fixture("module")
def dummy_send(mock_notification_info, mock_notification_service) -> DummyRequest:
    """
    returns a dummy request with a mocked notification info

    :return: DummyRequest with mock NotificationInfo
    """
    request = DummyRequest(
        notification_info=mock_notification_info,
        notification_service=mock_notification_service
    )
    return request