-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connect users in tracked mail tasks (#116)
* repair failing test, logging error in tracker.py * match created_by users on tracked email reciept * fix test and minor update * updates to mail trackingr and user connection
- Loading branch information
Showing
4 changed files
with
87 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
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
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,3 +58,59 @@ def test_tracker_task_creation(todo_setup, django_user_model): | |
Comment.objects.get( | ||
task=task, body__contains="test3 content", email_message_id="<[email protected]>" | ||
) | ||
|
||
def test_tracker_email_match(todo_setup, django_user_model, settings): | ||
""" | ||
Ensure that a user is added to new lists when sent from registered email | ||
""" | ||
settings.TODO_MAIL_USER_MAPPER = True | ||
|
||
u1 = django_user_model.objects.get(username="u1") | ||
|
||
msg = make_message("test1 subject", "test1 content") | ||
msg["From"] = u1.email | ||
msg["Message-ID"] = "<[email protected]>" | ||
|
||
# test task creation | ||
task_count = Task.objects.count() | ||
consumer([msg]) | ||
|
||
assert task_count + 1 == Task.objects.count(), "task wasn't created" | ||
task = Task.objects.filter(title="[TEST] test1 subject").first() | ||
assert task is not None, "task was created with the wrong name" | ||
assert task.created_by == u1 | ||
|
||
# Check no match | ||
msg = make_message("test2 subject", "test2 content") | ||
msg["From"] = "[email protected]" | ||
msg["Message-ID"] = "<[email protected]>" | ||
|
||
# test task creation | ||
task_count = Task.objects.count() | ||
consumer([msg]) | ||
|
||
assert task_count + 1 == Task.objects.count(), "task wasn't created" | ||
task = Task.objects.filter(title="[TEST] test2 subject").first() | ||
assert task.created_by == None | ||
|
||
|
||
def test_tracker_match_users_false(todo_setup, django_user_model, settings): | ||
""" | ||
Do not match users on incoming mail if TODO_MAIL_USER_MAPPER is False | ||
""" | ||
settings.TODO_MAIL_USER_MAPPER = None | ||
|
||
u1 = django_user_model.objects.get(username="u1") | ||
|
||
msg = make_message("test1 subject", "test1 content") | ||
msg["From"] = u1.email | ||
msg["Message-ID"] = "<[email protected]>" | ||
|
||
# test task creation | ||
task_count = Task.objects.count() | ||
consumer([msg]) | ||
|
||
assert task_count + 1 == Task.objects.count(), "task wasn't created" | ||
task = Task.objects.filter(title="[TEST] test1 subject").first() | ||
assert task is not None, "task was created with the wrong name" | ||
assert task.created_by == None |