-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
099fdcc
commit fbd66a5
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
@@ -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")) | ||
|