diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-16 11:13:13 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-09-16 11:13:13 -0300 |
commit | d016d6c08b4193a8a416506fcdb953a116d5990a (patch) | |
tree | 5d4c921de6c1ca7257dda0da8b6550ddf615b6a1 /fake-service/app | |
parent | ae87043b0ae3f934820ffaacd71c17bc328c0c03 (diff) |
fixing mail date parsing on fake service - we still use random data for the functional tests[
Diffstat (limited to 'fake-service/app')
-rw-r--r-- | fake-service/app/adapter/mail.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fake-service/app/adapter/mail.py b/fake-service/app/adapter/mail.py index 26c00277..fae3958c 100644 --- a/fake-service/app/adapter/mail.py +++ b/fake-service/app/adapter/mail.py @@ -74,11 +74,19 @@ class Mail: headers['from'] = mbox_mail.get('From') or mbox_mail.from_addr headers['to'] = [mbox_mail.get('To')] headers['subject'] = mbox_mail.get('Subject') - headers['date'] = parser.parse(mbox_mail['Date']).isoformat() + headers['date'] = self._get_date(mbox_mail) headers['content_type'] = mbox_mail.get('Content-Type') return headers + def _get_date(self, mbox_mail): + random_date = datetime.fromtimestamp(random.randrange(1222222222, self.NOW)).isoformat() + mbox_date = mbox_mail.get('Date') + + if not mbox_date: # means we are still using the mailsets - important for functional tests + return random_date + return parser.parse(mbox_mail['Date']).isoformat() + def _get_tags(self, mbox_mail): return filter(len, mbox_mail.get('X-TW-Pixelated-Tags').split(', ')) |