forked from MetricsGrimoire/MailingListStats
-
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.
Attempt to parse multiple messages in mbox and fix MetricsGrimoire#10
- Loading branch information
Showing
2 changed files
with
74 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
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 |
---|---|---|
|
@@ -34,7 +34,7 @@ def get_analyzer(self, path, **kwargs): | |
|
||
def check_single_message(self, expected, messages): | ||
for key, value in expected.items(): | ||
output = u"{}:\n" \ | ||
output = u"\n{}:\n" \ | ||
u"\tExpected: '{}'\n" \ | ||
u"\tObtained: '{}'".format(key, value, messages[0][key]) | ||
self.assertEqual(value, messages[0][key], output) | ||
|
@@ -45,7 +45,7 @@ def test_single_message_no_encoding(self): | |
expected = { | ||
'body': u'Hi!\n\nA message in English, with a signature ' | ||
u'with a different encoding.\n\nregards, G?ran' | ||
u'\n\n\n\n', | ||
u'\n\n\n', | ||
'content-type': None, | ||
'date': '2010-12-01 14:26:40', | ||
'date_tz': '3600', | ||
|
@@ -113,7 +113,7 @@ def test_single_message_with_8_bit_encoding(self): | |
u'> desktop-devel-list mailing list\n' | ||
u'> [email protected]\n' | ||
u'> http://mail.gnome.org/mailman/listinfo/desktop-devel-list' | ||
u'\n\n', | ||
u'\n', | ||
'content-type': u'text/plain; charset=utf-8', | ||
'date': '2008-03-17 11:19:29', | ||
'date_tz': '3600', | ||
|
@@ -180,3 +180,35 @@ def test_single_message_with_7_bit_encoding(self): | |
self.assertEqual(1, len(messages), '# of messages') | ||
self.check_single_message(expected, messages) | ||
self.assertEqual(0, non_parsed, 'non_parsed') | ||
|
||
def test_single_message_tricky(self): | ||
'''Multiple From's that are not new messages''' | ||
maa = self.get_analyzer('mlstats-2007.mbox') | ||
messages, non_parsed = maa.get_messages() | ||
expected = { | ||
'body': | ||
u'Vaya, olvid? los archivos que testifican todo esto. Ah? van.' | ||
u'\n\n' | ||
u'> Libresoft-tools-devel mailing list\n' | ||
u'> Libresoft-tools-devel at lists.morfeo-project.org\n' | ||
u'-------------- next part --------------\n' | ||
u'From erkko.anttila at nokia.com Mon Aug 1 12:51:16 2005\n' | ||
u'From florian.boor at kernelconcepts.de Mon Aug 1 13:12:02 2005' | ||
u'\nFrom czr770 at iohazard.tts.fi Mon Aug 1 14:43:49 2005' | ||
u'\n', | ||
'content-type': None, | ||
'date': '2007-02-14 19:46:10', | ||
'date_tz': '0', | ||
'in-reply-to': u'<[email protected]>', | ||
'list-id': None, | ||
'message-id': u'<[email protected]>', | ||
'received': None, | ||
'references': u'<[email protected]>', | ||
'from': [(u'Jorge Gascon Perez', u'[email protected]')], | ||
'to': None, | ||
'cc': None | ||
} | ||
|
||
self.check_single_message(expected, messages) | ||
self.assertEqual(2, len(messages), '# of messages') | ||
self.assertEqual(0, non_parsed, 'non_parsed') |