Formatting

This commit is contained in:
Scot Hacker 2019-04-12 00:09:01 -07:00
parent 4a385bde6b
commit befc7ad2cd
28 changed files with 253 additions and 311 deletions

View file

@ -9,24 +9,21 @@ from email.message import EmailMessage
def consumer(*args, title_format="[TEST] {subject}", **kwargs):
return tracker_consumer(
group="Workgroup One",
task_list_slug="zip",
priority=1,
task_title_format=title_format,
group="Workgroup One", task_list_slug="zip", priority=1, task_title_format=title_format
)(*args, **kwargs)
def make_message(subject, content):
msg = EmailMessage()
msg.set_content(content)
msg['Subject'] = subject
msg["Subject"] = subject
return msg
def test_tracker_task_creation(todo_setup, django_user_model):
msg = make_message("test1 subject", "test1 content")
msg['From'] = 'test1@example.com'
msg['Message-ID'] = '<a@example.com>'
msg["From"] = "test1@example.com"
msg["Message-ID"] = "<a@example.com>"
# test task creation
task_count = Task.objects.count()
@ -38,30 +35,26 @@ def test_tracker_task_creation(todo_setup, django_user_model):
# test thread answers
msg = make_message("test2 subject", "test2 content")
msg['From'] = 'test1@example.com'
msg['Message-ID'] = '<b@example.com>'
msg['References'] = '<nope@example.com> <a@example.com>'
msg["From"] = "test1@example.com"
msg["Message-ID"] = "<b@example.com>"
msg["References"] = "<nope@example.com> <a@example.com>"
task_count = Task.objects.count()
consumer([msg])
assert task_count == Task.objects.count(), "comment created another task"
Comment.objects.get(
task=task,
body__contains="test2 content",
email_message_id='<b@example.com>'
task=task, body__contains="test2 content", email_message_id="<b@example.com>"
)
# test notification answer
msg = make_message("test3 subject", "test3 content")
msg['From'] = 'test1@example.com'
msg['Message-ID'] = '<c@example.com>'
msg['References'] = '<thread-{}@django-todo> <unknown@example.com>'.format(task.pk)
msg["From"] = "test1@example.com"
msg["Message-ID"] = "<c@example.com>"
msg["References"] = "<thread-{}@django-todo> <unknown@example.com>".format(task.pk)
task_count = Task.objects.count()
consumer([msg])
assert task_count == Task.objects.count(), "comment created another task"
Comment.objects.get(
task=task,
body__contains="test3 content",
email_message_id='<c@example.com>'
task=task, body__contains="test3 content", email_message_id="<c@example.com>"
)