-
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.
Provide tests for message flags, message age, and the Boolean Not ope…
…rator.
- Loading branch information
Thomi Richards
committed
Jul 5, 2015
1 parent
f599b34
commit 32231f2
Showing
4 changed files
with
155 additions
and
5 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 |
---|---|---|
@@ -1,2 +0,0 @@ | ||
|
||
|
||
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,32 +1,48 @@ | ||
"""Test factory for gmailfilter tests.""" | ||
|
||
import datetime | ||
|
||
from gmailfilter._message import Message | ||
|
||
|
||
class TestFactoryMixin(object): | ||
|
||
"""A mixin class that generates test fake values.""" | ||
|
||
def get_email_message(self, headers=None, subject='Test Subject'): | ||
def get_email_message(self, headers=None, subject='Test Subject', | ||
flags=None, date=None): | ||
"""Get an email message. | ||
:param headers: If set, must be a dict or 2-tuple iteratble of key/value | ||
pairs that will be set as the email message header values. | ||
:param headers: If set, must be a dict or 2-tuple iteratble of | ||
key/value pairs that will be set as the email message header | ||
values. | ||
""" | ||
message = FakeMessage() | ||
if headers: | ||
message.headers = dict(headers) | ||
message.headers['Subject'] = subject | ||
if flags: | ||
message.flags = flags | ||
if date is not None: | ||
message.date = date | ||
return message | ||
|
||
|
||
class FakeMessage(Message): | ||
|
||
def __init__(self): | ||
self.headers = {} | ||
self.flags = () | ||
self.date = datetime.datetime.utcnow() | ||
|
||
def get_headers(self): | ||
return self.headers | ||
|
||
def subject(self): | ||
return self.get_headers()['Subject'] | ||
|
||
def get_flags(self): | ||
return self.flags | ||
|
||
def get_date(self): | ||
return self.date |
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