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()

[((13, 11, 13, 22), 'rest_framework.test.APIClient', 'APIClient', ({}, {}), '()', False, 'from rest_framework.test import APIClient\n'), ((18, 19, 18, 32), 'django.http.HttpRequest', 'HttpRequest', ({}, {}), '()', False, 'from django.http import HttpRequest\n'), ((25, 15, 25, 25), 'rest_framework.response.Response', 'Response', ({}, {}), '()', False, 'from rest_framework.response import Response\n'), ((26, 38, 26, 49), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((34, 26, 34, 37), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n'), ((41, 11, 41, 42), 'drf_viewset_profiler.middleware.LineProfilerViewSetMiddleware', 'LineProfilerViewSetMiddleware', ({}, {}), '()', False, 'from drf_viewset_profiler.middleware import LineProfilerViewSetMiddleware\n'), ((27, 48, 27, 59), 'unittest.mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'from unittest import mock\n')]