from unittest import mock

import pytest
from django.http import HttpRequest
from rest_framework.response import Response
from rest_framework.test import APIClient

from drf_viewset_profiler.middleware import LineProfilerViewSetMiddleware


@pytest.fixture
def api_client():
    return APIClient()


@pytest.fixture
def mock_http_request():
    http_request = HttpRequest()
    http_request.method = "GET"
    return http_request


@pytest.fixture
def mock_http_response(mock_http_request):
    response = Response()
    mock_http_request.line_profiler = mock.Mock()
    mock_http_request.parser_context = {"view": mock.Mock()}
    response.renderer_context = {"request": mock_http_request}
    return response


@pytest.fixture
def mock_output_writer(monkeypatch):
    mock_output_writer_ = mock.Mock()
    monkeypatch.setattr("drf_viewset_profiler.middleware.output_writer.stream", mock_output_writer_)
    return mock_output_writer_


@pytest.fixture
def mock_line_profiler_viewset_middleware():
    return LineProfilerViewSetMiddleware()

[((286, 297), 'rest_framework.test.APIClient', 'APIClient', ([], {}), '()\n', (295, 297), False, 'from rest_framework.test import APIClient\n'), ((360, 373), 'django.http.HttpRequest', 'HttpRequest', ([], {}), '()\n', (371, 373), False, 'from django.http import HttpRequest\n'), ((506, 516), 'rest_framework.response.Response', 'Response', ([], {}), '()\n', (514, 516), False, 'from rest_framework.response import Response\n'), ((555, 566), 'unittest.mock.Mock', 'mock.Mock', ([], {}), '()\n', (564, 566), False, 'from unittest import mock\n'), ((792, 803), 'unittest.mock.Mock', 'mock.Mock', ([], {}), '()\n', (801, 803), False, 'from unittest import mock\n'), ((1010, 1041), 'drf_viewset_profiler.middleware.LineProfilerViewSetMiddleware', 'LineProfilerViewSetMiddleware', ([], {}), '()\n', (1039, 1041), False, 'from drf_viewset_profiler.middleware import LineProfilerViewSetMiddleware\n'), ((615, 626), 'unittest.mock.Mock', 'mock.Mock', ([], {}), '()\n', (624, 626), False, 'from unittest import mock\n')]