-
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.
Merge pull request #46 from smkent/ignore-missing-identity
Continue processing email threads on email handle callback error
- Loading branch information
Showing
3 changed files
with
54 additions
and
3 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 |
---|---|---|
|
@@ -58,7 +58,9 @@ def make_email_event( | |
) | ||
|
||
|
||
def make_identity_get_response() -> IdentityGetResponse: | ||
def make_identity_get_response( | ||
email: str = "[email protected]", | ||
) -> IdentityGetResponse: | ||
return IdentityGetResponse( | ||
account_id="u1138", | ||
state="2187", | ||
|
@@ -67,7 +69,7 @@ def make_identity_get_response() -> IdentityGetResponse: | |
Identity( | ||
id="ID1", | ||
name="ness", | ||
email="[email protected]", | ||
email=email, | ||
reply_to="[email protected]", | ||
bcc=None, | ||
text_signature=None, | ||
|
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 |
---|---|---|
|
@@ -176,6 +176,52 @@ def test_wafflesbot( | |
mock_request() | ||
|
||
|
||
def test_wafflesbot_no_matching_identity( | ||
wafflesbot: Waffles, | ||
mock_request: mock.MagicMock, | ||
mock_events: List[sseclient.Event], | ||
) -> None: | ||
original_email_read = False | ||
original_email_in_inbox = True | ||
wafflesbot.client.live_mode = True | ||
mock_events.append(make_email_event(email_state="1118")) | ||
mock_events.append(make_email_event(email_state="1119")) | ||
expected_calls: List[mock._Call] = [] | ||
expected_calls.append(make_mailbox_get_call("pigeonhole")) | ||
expected_calls.append(make_email_changes_call(since_state="1118")) | ||
expected_calls.append( | ||
make_email_get_call(properties=["threadId", "mailboxIds"]) | ||
) | ||
expected_calls.append(make_thread_get_call()) | ||
expected_calls.append(make_email_get_call(fetch_all_body_values=True)) | ||
expected_calls.append(mock.call(IdentityGet())) | ||
mock_responses: List[Any] = [] | ||
mock_responses.append(make_mailbox_get_response("MBX50", "pigeonhole")) | ||
mock_responses.append(make_email_changes_response()) | ||
mock_responses.append( | ||
make_email_get_response( | ||
is_read=original_email_read, | ||
is_in_inbox=original_email_in_inbox, | ||
additional_mailbox="MBX50", | ||
) | ||
) | ||
mock_responses.append(make_thread_get_response()) | ||
mock_responses.append( | ||
make_email_get_response( | ||
is_read=original_email_read, | ||
is_in_inbox=original_email_in_inbox, | ||
) | ||
) | ||
mock_responses.append( | ||
make_identity_get_response(email="[email protected]") | ||
) | ||
mock_request.side_effect = mock_responses | ||
wafflesbot.run(events=True) | ||
assert_or_debug_calls(mock_request.call_args_list, expected_calls) | ||
with pytest.raises(StopIteration): | ||
mock_request() | ||
|
||
|
||
@pytest.mark.parametrize("dry_run", [True, False], ids=["dry_run", "live"]) | ||
@pytest.mark.parametrize( | ||
"in_folder", [True, False], ids=["in_folder", "not_in_folder"] | ||
|
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