Python mailbox.BabylMessage() Examples
The following are 30
code examples of mailbox.BabylMessage().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mailbox
, or try the search function
.
Example #1
Source File: test_mailbox.py From oss-ftp with MIT License | 6 votes |
def test_babyl_to_maildir(self): # Convert BabylMessage to MaildirMessage pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'), ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'), ('resent', 'PS')) for setting, result in pairs: msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result) self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT') self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')
Example #2
Source File: test_mailbox.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_labels(self): # Get, set, join, and leave labels msg = mailbox.BabylMessage(_sample_message) self.assertEqual(msg.get_labels(), []) msg.set_labels(['foobar']) self.assertEqual(msg.get_labels(), ['foobar']) msg.set_labels([]) self.assertEqual(msg.get_labels(), []) msg.add_label('filed') self.assertEqual(msg.get_labels(), ['filed']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.remove_label('filed') self.assertEqual(msg.get_labels(), ['resent']) msg.add_label('foobar') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.remove_label('unseen') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.set_labels(['foobar', 'answered']) self.assertEqual(msg.get_labels(), ['foobar', 'answered'])
Example #3
Source File: test_mailbox.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_visible(self): # Get, set, and update visible headers msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assertEqual(visible.keys(), []) self.assertIsNone(visible.get_payload()) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assertEqual(msg.get_visible().keys(), []) msg.set_visible(visible) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertEqual(visible['User-Agent'], 'FooBar 1.0') self.assertEqual(visible['X-Whatever'], 'Blah') self.assertIsNone(visible.get_payload()) msg.update_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertIsNone(visible.get_payload()) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To', 'Subject']) for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'): self.assertEqual(visible[header], msg[header])
Example #4
Source File: test_mailbox.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_labels(self): # Get, set, join, and leave labels msg = mailbox.BabylMessage(_sample_message) self.assertEqual(msg.get_labels(), []) msg.set_labels(['foobar']) self.assertEqual(msg.get_labels(), ['foobar']) msg.set_labels([]) self.assertEqual(msg.get_labels(), []) msg.add_label('filed') self.assertEqual(msg.get_labels(), ['filed']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.remove_label('filed') self.assertEqual(msg.get_labels(), ['resent']) msg.add_label('foobar') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.remove_label('unseen') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.set_labels(['foobar', 'answered']) self.assertEqual(msg.get_labels(), ['foobar', 'answered'])
Example #5
Source File: test_mailbox.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_visible(self): # Get, set, and update visible headers msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assert_(visible.keys() == []) self.assert_(visible.get_payload() is None) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assert_(msg.get_visible().keys() == []) msg.set_visible(visible) visible = msg.get_visible() self.assert_(visible.keys() == ['User-Agent', 'X-Whatever']) self.assert_(visible['User-Agent'] == 'FooBar 1.0') self.assert_(visible['X-Whatever'] == 'Blah') self.assert_(visible.get_payload() is None) msg.update_visible() self.assert_(visible.keys() == ['User-Agent', 'X-Whatever']) self.assert_(visible.get_payload() is None) visible = msg.get_visible() self.assert_(visible.keys() == ['User-Agent', 'Date', 'From', 'To', 'Subject']) for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'): self.assert_(visible[header] == msg[header])
Example #6
Source File: test_mailbox.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_babyl_to_mboxmmdf(self): # Convert BabylMessage to mboxMessage and MMDFMessage pairs = (('unseen', 'O'), ('deleted', 'ROD'), ('filed', 'RO'), ('answered', 'ROA'), ('forwarded', 'RO'), ('edited', 'RO'), ('resent', 'RO')) for setting, result in pairs: for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage): msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(class_(msg).get_flags(), result) msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage): self.assertEqual(class_(msg).get_flags(), 'ODA')
Example #7
Source File: test_mailbox.py From BinderFilter with MIT License | 6 votes |
def test_labels(self): # Get labels from the mailbox self.assertEqual(self._box.get_labels(), []) msg0 = mailbox.BabylMessage(self._template % 0) msg0.add_label('foo') key0 = self._box.add(msg0) self.assertEqual(self._box.get_labels(), ['foo']) msg1 = mailbox.BabylMessage(self._template % 1) msg1.set_labels(['bar', 'answered', 'foo']) key1 = self._box.add(msg1) self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar'])) msg0.set_labels(['blah', 'filed']) self._box[key0] = msg0 self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar', 'blah'])) self._box.remove(key1) self.assertEqual(set(self._box.get_labels()), set(['blah']))
Example #8
Source File: test_mailbox.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_babyl_to_maildir(self): # Convert BabylMessage to MaildirMessage pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'), ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'), ('resent', 'PS')) for setting, result in pairs: msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result) self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT') self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')
Example #9
Source File: test_mailbox.py From BinderFilter with MIT License | 6 votes |
def test_labels(self): # Get, set, join, and leave labels msg = mailbox.BabylMessage(_sample_message) self.assertEqual(msg.get_labels(), []) msg.set_labels(['foobar']) self.assertEqual(msg.get_labels(), ['foobar']) msg.set_labels([]) self.assertEqual(msg.get_labels(), []) msg.add_label('filed') self.assertEqual(msg.get_labels(), ['filed']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.remove_label('filed') self.assertEqual(msg.get_labels(), ['resent']) msg.add_label('foobar') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.remove_label('unseen') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.set_labels(['foobar', 'answered']) self.assertEqual(msg.get_labels(), ['foobar', 'answered'])
Example #10
Source File: test_mailbox.py From BinderFilter with MIT License | 6 votes |
def test_visible(self): # Get, set, and update visible headers msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assertEqual(visible.keys(), []) self.assertIs(visible.get_payload(), None) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assertEqual(msg.get_visible().keys(), []) msg.set_visible(visible) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertEqual(visible['User-Agent'], 'FooBar 1.0') self.assertEqual(visible['X-Whatever'], 'Blah') self.assertIs(visible.get_payload(), None) msg.update_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertIs(visible.get_payload(), None) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To', 'Subject']) for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'): self.assertEqual(visible[header], msg[header])
Example #11
Source File: test_mailbox.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_babyl_to_maildir(self): # Convert BabylMessage to MaildirMessage pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'), ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'), ('resent', 'PS')) for setting, result in pairs: msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result) self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT') self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')
Example #12
Source File: test_mailbox.py From BinderFilter with MIT License | 6 votes |
def test_babyl_to_maildir(self): # Convert BabylMessage to MaildirMessage pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'), ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'), ('resent', 'PS')) for setting, result in pairs: msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result) self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT') self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')
Example #13
Source File: test_mailbox.py From oss-ftp with MIT License | 6 votes |
def test_labels(self): # Get labels from the mailbox self.assertEqual(self._box.get_labels(), []) msg0 = mailbox.BabylMessage(self._template % 0) msg0.add_label('foo') key0 = self._box.add(msg0) self.assertEqual(self._box.get_labels(), ['foo']) msg1 = mailbox.BabylMessage(self._template % 1) msg1.set_labels(['bar', 'answered', 'foo']) key1 = self._box.add(msg1) self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar'])) msg0.set_labels(['blah', 'filed']) self._box[key0] = msg0 self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar', 'blah'])) self._box.remove(key1) self.assertEqual(set(self._box.get_labels()), set(['blah']))
Example #14
Source File: test_mailbox.py From oss-ftp with MIT License | 6 votes |
def test_labels(self): # Get, set, join, and leave labels msg = mailbox.BabylMessage(_sample_message) self.assertEqual(msg.get_labels(), []) msg.set_labels(['foobar']) self.assertEqual(msg.get_labels(), ['foobar']) msg.set_labels([]) self.assertEqual(msg.get_labels(), []) msg.add_label('filed') self.assertEqual(msg.get_labels(), ['filed']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.remove_label('filed') self.assertEqual(msg.get_labels(), ['resent']) msg.add_label('foobar') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.remove_label('unseen') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.set_labels(['foobar', 'answered']) self.assertEqual(msg.get_labels(), ['foobar', 'answered'])
Example #15
Source File: test_mailbox.py From oss-ftp with MIT License | 6 votes |
def test_visible(self): # Get, set, and update visible headers msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assertEqual(visible.keys(), []) self.assertIsNone(visible.get_payload()) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assertEqual(msg.get_visible().keys(), []) msg.set_visible(visible) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertEqual(visible['User-Agent'], 'FooBar 1.0') self.assertEqual(visible['X-Whatever'], 'Blah') self.assertIsNone(visible.get_payload()) msg.update_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertIsNone(visible.get_payload()) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To', 'Subject']) for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'): self.assertEqual(visible[header], msg[header])
Example #16
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_babyl_to_maildir(self): # Convert BabylMessage to MaildirMessage pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'), ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'), ('resent', 'PS')) for setting, result in pairs: msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result) self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT') self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')
Example #17
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_visible(self): # Get, set, and update visible headers msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assertEqual(visible.keys(), []) self.assertIsNone(visible.get_payload()) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assertEqual(msg.get_visible().keys(), []) msg.set_visible(visible) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertEqual(visible['User-Agent'], 'FooBar 1.0') self.assertEqual(visible['X-Whatever'], 'Blah') self.assertIsNone(visible.get_payload()) msg.update_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertIsNone(visible.get_payload()) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To', 'Subject']) for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'): self.assertEqual(visible[header], msg[header])
Example #18
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_labels(self): # Get, set, join, and leave labels msg = mailbox.BabylMessage(_sample_message) self.assertEqual(msg.get_labels(), []) msg.set_labels(['foobar']) self.assertEqual(msg.get_labels(), ['foobar']) msg.set_labels([]) self.assertEqual(msg.get_labels(), []) msg.add_label('filed') self.assertEqual(msg.get_labels(), ['filed']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.remove_label('filed') self.assertEqual(msg.get_labels(), ['resent']) msg.add_label('foobar') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.remove_label('unseen') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.set_labels(['foobar', 'answered']) self.assertEqual(msg.get_labels(), ['foobar', 'answered'])
Example #19
Source File: test_mailbox.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_labels(self): # Get labels from the mailbox self.assertEqual(self._box.get_labels(), []) msg0 = mailbox.BabylMessage(self._template % 0) msg0.add_label('foo') key0 = self._box.add(msg0) self.assertEqual(self._box.get_labels(), ['foo']) msg1 = mailbox.BabylMessage(self._template % 1) msg1.set_labels(['bar', 'answered', 'foo']) key1 = self._box.add(msg1) self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar'])) msg0.set_labels(['blah', 'filed']) self._box[key0] = msg0 self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar', 'blah'])) self._box.remove(key1) self.assertEqual(set(self._box.get_labels()), set(['blah']))
Example #20
Source File: test_mailbox.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_labels(self): # Get, set, join, and leave labels msg = mailbox.BabylMessage(_sample_message) self.assertEqual(msg.get_labels(), []) msg.set_labels(['foobar']) self.assertEqual(msg.get_labels(), ['foobar']) msg.set_labels([]) self.assertEqual(msg.get_labels(), []) msg.add_label('filed') self.assertEqual(msg.get_labels(), ['filed']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.remove_label('filed') self.assertEqual(msg.get_labels(), ['resent']) msg.add_label('foobar') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.remove_label('unseen') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.set_labels(['foobar', 'answered']) self.assertEqual(msg.get_labels(), ['foobar', 'answered'])
Example #21
Source File: test_mailbox.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_visible(self): # Get, set, and update visible headers msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assertEqual(visible.keys(), []) self.assertIsNone(visible.get_payload()) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assertEqual(msg.get_visible().keys(), []) msg.set_visible(visible) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertEqual(visible['User-Agent'], 'FooBar 1.0') self.assertEqual(visible['X-Whatever'], 'Blah') self.assertIsNone(visible.get_payload()) msg.update_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertIsNone(visible.get_payload()) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To', 'Subject']) for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'): self.assertEqual(visible[header], msg[header])
Example #22
Source File: test_mailbox.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_labels(self): # Get labels from the mailbox self.assertEqual(self._box.get_labels(), []) msg0 = mailbox.BabylMessage(self._template % 0) msg0.add_label('foo') key0 = self._box.add(msg0) self.assertEqual(self._box.get_labels(), ['foo']) msg1 = mailbox.BabylMessage(self._template % 1) msg1.set_labels(['bar', 'answered', 'foo']) key1 = self._box.add(msg1) self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar'])) msg0.set_labels(['blah', 'filed']) self._box[key0] = msg0 self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar', 'blah'])) self._box.remove(key1) self.assertEqual(set(self._box.get_labels()), set(['blah']))
Example #23
Source File: test_mailbox.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_babyl_to_maildir(self): # Convert BabylMessage to MaildirMessage pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'), ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'), ('resent', 'PS')) for setting, result in pairs: msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result) self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT') self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')
Example #24
Source File: test_mailbox.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_babyl_to_mboxmmdf(self): # Convert BabylMessage to mboxMessage and MMDFMessage pairs = (('unseen', 'O'), ('deleted', 'ROD'), ('filed', 'RO'), ('answered', 'ROA'), ('forwarded', 'RO'), ('edited', 'RO'), ('resent', 'RO')) for setting, result in pairs: for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage): msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(class_(msg).get_flags(), result) msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage): self.assertEqual(class_(msg).get_flags(), 'ODA')
Example #25
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_labels(self): # Get labels from the mailbox self.assertEqual(self._box.get_labels(), []) msg0 = mailbox.BabylMessage(self._template % 0) msg0.add_label('foo') key0 = self._box.add(msg0) self.assertEqual(self._box.get_labels(), ['foo']) msg1 = mailbox.BabylMessage(self._template % 1) msg1.set_labels(['bar', 'answered', 'foo']) key1 = self._box.add(msg1) self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar'])) msg0.set_labels(['blah', 'filed']) self._box[key0] = msg0 self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar', 'blah'])) self._box.remove(key1) self.assertEqual(set(self._box.get_labels()), set(['blah']))
Example #26
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_labels(self): # Get labels from the mailbox self.assertEqual(self._box.get_labels(), []) msg0 = mailbox.BabylMessage(self._template % 0) msg0.add_label('foo') key0 = self._box.add(msg0) self.assertEqual(self._box.get_labels(), ['foo']) msg1 = mailbox.BabylMessage(self._template % 1) msg1.set_labels(['bar', 'answered', 'foo']) key1 = self._box.add(msg1) self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar'])) msg0.set_labels(['blah', 'filed']) self._box[key0] = msg0 self.assertEqual(set(self._box.get_labels()), set(['foo', 'bar', 'blah'])) self._box.remove(key1) self.assertEqual(set(self._box.get_labels()), set(['blah']))
Example #27
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_labels(self): # Get, set, join, and leave labels msg = mailbox.BabylMessage(_sample_message) self.assertEqual(msg.get_labels(), []) msg.set_labels(['foobar']) self.assertEqual(msg.get_labels(), ['foobar']) msg.set_labels([]) self.assertEqual(msg.get_labels(), []) msg.add_label('filed') self.assertEqual(msg.get_labels(), ['filed']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.add_label('resent') self.assertEqual(msg.get_labels(), ['filed', 'resent']) msg.remove_label('filed') self.assertEqual(msg.get_labels(), ['resent']) msg.add_label('foobar') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.remove_label('unseen') self.assertEqual(msg.get_labels(), ['resent', 'foobar']) msg.set_labels(['foobar', 'answered']) self.assertEqual(msg.get_labels(), ['foobar', 'answered'])
Example #28
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_visible(self): # Get, set, and update visible headers msg = mailbox.BabylMessage(_sample_message) visible = msg.get_visible() self.assertEqual(visible.keys(), []) self.assertIsNone(visible.get_payload()) visible['User-Agent'] = 'FooBar 1.0' visible['X-Whatever'] = 'Blah' self.assertEqual(msg.get_visible().keys(), []) msg.set_visible(visible) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertEqual(visible['User-Agent'], 'FooBar 1.0') self.assertEqual(visible['X-Whatever'], 'Blah') self.assertIsNone(visible.get_payload()) msg.update_visible() self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever']) self.assertIsNone(visible.get_payload()) visible = msg.get_visible() self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To', 'Subject']) for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'): self.assertEqual(visible[header], msg[header])
Example #29
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_babyl_to_mboxmmdf(self): # Convert BabylMessage to mboxMessage and MMDFMessage pairs = (('unseen', 'O'), ('deleted', 'ROD'), ('filed', 'RO'), ('answered', 'ROA'), ('forwarded', 'RO'), ('edited', 'RO'), ('resent', 'RO')) for setting, result in pairs: for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage): msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(class_(msg).get_flags(), result) msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage): self.assertEqual(class_(msg).get_flags(), 'ODA')
Example #30
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_babyl_to_maildir(self): # Convert BabylMessage to MaildirMessage pairs = (('unseen', ''), ('deleted', 'ST'), ('filed', 'S'), ('answered', 'RS'), ('forwarded', 'PS'), ('edited', 'S'), ('resent', 'PS')) for setting, result in pairs: msg = mailbox.BabylMessage(_sample_message) msg.add_label(setting) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), result) self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur') msg = mailbox.BabylMessage(_sample_message) for label in ('unseen', 'deleted', 'filed', 'answered', 'forwarded', 'edited', 'resent'): msg.add_label(label) self.assertEqual(mailbox.MaildirMessage(msg).get_flags(), 'PRT') self.assertEqual(mailbox.MaildirMessage(msg).get_subdir(), 'cur')