Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjambrecic committed Nov 21, 2024
1 parent 099fdcc commit fbd66a5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/deployment/test_main_1_fastapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from io import BytesIO
from pathlib import Path

import pandas as pd
import pytest
from _pytest.monkeypatch import MonkeyPatch
from fastapi import UploadFile
from fastapi.testclient import TestClient

Expand All @@ -10,6 +13,21 @@
class TestApp:
client = TestClient(app)

@pytest.fixture(autouse=True)
def patch_uploaded_files_dir(
self, tmp_path: Path, monkeypatch: MonkeyPatch
) -> Path:
uploaded_files_dir = tmp_path / "uploads"
uploaded_files_dir.mkdir(exist_ok=True)

monkeypatch.setattr(
"mailchimp_api.deployment.main_1_fastapi.UPLOADED_FILES_DIR",
uploaded_files_dir,
)

# Return the temporary directory so it can be used in tests if needed
return uploaded_files_dir

def test_save_file(self) -> None:
csv_content = "email\n[email protected]\n[email protected]"
csv_file = BytesIO(csv_content.encode("utf-8"))
Expand Down

0 comments on commit fbd66a5

Please sign in to comment.