Skip to content

Instantly share code, notes, and snippets.

@JaviMiot
Last active October 4, 2022 19:30
Show Gist options
  • Save JaviMiot/14fd557721b6a37f9200fef02bb9428b to your computer and use it in GitHub Desktop.
Save JaviMiot/14fd557721b6a37f9200fef02bb9428b to your computer and use it in GitHub Desktop.
client_cache
# flake8: noqa
import pytest
from fastapi.testclient import TestClient
from .fixtures.quantifier import project_employee_mock, create_project_employees
from .fixtures.quantifier import create_ptos, pto_mock
from .fixtures.quantifier import calculate_days_between_dates
from .fixtures.quantifier import generate_range_date
from .fixtures.data import holiday_data, employee_data, notion_data
from .fixtures.auth import get_session_mock, request_mock, auth_service_client
from .fixtures.settings import settings
from .fixtures.employee_manager import client_employee, client_pto, drivers
from .fixtures.project_manager import client_projects, driver_notion
@pytest.fixture
def client():
from app.main import app
with TestClient(app) as client:
yield client
from http import client
import re
import pytest
from app.main import app
from fastapi.testclient import TestClient
from fastapi import HTTPException
from app.middleware.auth import AuthServiceClient
async def auth_service_client_override():
raise HTTPException(500)
@pytest.fixture()
def client_with_custom_session(client):
client.app.dependency_overrides[AuthServiceClient.validate('report')] = auth_service_client_override
return client
def test_generate_report(client_with_custom_session):
response = client_with_custom_session.get('/report/2022/9')
assert response.status_code == 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment