Skip to content

Commit

Permalink
Tests update and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rjambrecic committed Nov 21, 2024
1 parent fbd66a5 commit af4fbb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mailchimp_api/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _get_config() -> Config:
config = _get_config()


@wf.register(name="simple_learning", description="Student and teacher learning chat") # type: ignore[misc]
@wf.register(name="mailchimp_chat", description="Mailchimp tags update chat") # type: ignore[misc]
def simple_workflow(ui: UI, params: dict[str, Any]) -> str:
timestamp = time.strftime("%Y-%m-%d-%H-%M-%S")
body = f"""Please upload **.csv** file with the email addresses for which you want to update the tags.
Expand Down
11 changes: 11 additions & 0 deletions tests/deployment/test_main_1_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,14 @@ def test_upload_endpoint_raises_400_error_if_file_is_not_csv(self) -> None:
)
assert response.status_code == 400
assert "Only CSV files are supported" in response.text

def test_upload_endpoint_raises_400_error_if_email_column_not_found(self) -> None:
csv_content = "name\n"
csv_file = BytesIO(csv_content.encode("utf-8"))
response = self.client.post(
"/upload",
files={"file": ("emails.csv", csv_file)},
data={"timestamp": "test-22-09-2021"},
)
assert response.status_code == 400
assert "'email' column not found in CSV file" in response.text

0 comments on commit af4fbb0

Please sign in to comment.