-
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
af4fbb0
commit c630241
Showing
2 changed files
with
76 additions
and
20 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
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,19 +1,52 @@ | ||
from uuid import uuid4 | ||
from unittest.mock import MagicMock, call, patch | ||
|
||
import pytest | ||
from fastagency.ui.console import ConsoleUI | ||
import pandas as pd | ||
|
||
from mailchimp_api.workflow import wf | ||
from tests.conftest import InputMock | ||
|
||
|
||
@pytest.mark.skip(reason="Skipping tests for now") | ||
def test_workflow(monkeypatch: pytest.MonkeyPatch) -> None: | ||
monkeypatch.setattr("builtins.input", InputMock([""] * 5)) | ||
def test_workflow() -> None: | ||
ui = MagicMock() | ||
ui.text_message.return_value = None | ||
ui.text_input.return_value = "test-list" | ||
|
||
result = wf.run( | ||
name="simple_learning", | ||
ui=ConsoleUI().create_workflow_ui(workflow_uuid=uuid4().hex), | ||
) | ||
with ( | ||
patch( | ||
"mailchimp_api.workflow._wait_for_file", | ||
return_value=pd.DataFrame({"email": ["[email protected]"]}), | ||
) as mock_wait_for_file, | ||
patch("mailchimp_api.workflow.update_tags") as mock_update_tags, | ||
): | ||
mock_update_tags.return_value = ( | ||
{ | ||
"M4": ["a", "b"], | ||
"M5": ["c", "d", "e"], | ||
"M3": ["f"], | ||
}, | ||
{}, | ||
) | ||
result = wf.run( | ||
name="mailchimp_chat", | ||
ui=ui, | ||
) | ||
|
||
mock_wait_for_file.assert_called_once() | ||
mock_update_tags.assert_called_once() | ||
|
||
expected_body = """Number of updates per tag: | ||
- **M3**: 1 | ||
- **M4**: 2 | ||
- **M5**: 3 | ||
(It might take some time for updates to reflect in Mailchimp) | ||
""" | ||
expected_call_args = call( | ||
sender="Workflow", | ||
recipient="User", | ||
body=expected_body, | ||
) | ||
|
||
assert ui.text_message.call_args_list[1] == expected_call_args | ||
|
||
assert result is not None |