Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions | Static Private Attributes
test.test_mailbox.TestBabylMessage Class Reference
Inheritance diagram for test.test_mailbox.TestBabylMessage:
Inheritance graph
[legend]
Collaboration diagram for test.test_mailbox.TestBabylMessage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_labels
def test_visible
def setUp
def tearDown
def test_initialize_with_eMM
def test_initialize_with_string
def test_initialize_with_file
def test_initialize_with_binary_file
def test_initialize_with_nothing
def test_initialize_incorrectly
def test_become_message
def test_explain_to

Private Member Functions

def _post_initialize_hook

Static Private Attributes

 _factory = mailbox.BabylMessage

Detailed Description

Definition at line 1479 of file test_mailbox.py.


Member Function Documentation

def test.test_mailbox.TestBabylMessage._post_initialize_hook (   self,
  msg 
) [private]

Reimplemented from test.test_mailbox.TestMessage.

Definition at line 1483 of file test_mailbox.py.

01483 
01484     def _post_initialize_hook(self, msg):
01485         self.assertEqual(msg._labels, [])

Here is the call graph for this function:

def test.test_mailbox.TestMessage.setUp (   self) [inherited]

Definition at line 1246 of file test_mailbox.py.

01246 
01247     def setUp(self):
01248         self._path = support.TESTFN

Here is the caller graph for this function:

def test.test_mailbox.TestMessage.tearDown (   self) [inherited]

Definition at line 1249 of file test_mailbox.py.

01249 
01250     def tearDown(self):
01251         self._delete_recursively(self._path)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1298 of file test_mailbox.py.

01298 
01299     def test_become_message(self):
01300         # Take on the state of another message
01301         eMM = email.message_from_string(_sample_message)
01302         msg = self._factory()
01303         msg._become_message(eMM)
01304         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1305 of file test_mailbox.py.

01305 
01306     def test_explain_to(self):
01307         # Copy self's format-specific data to other message formats.
01308         # This test is superficial; better ones are in TestMessageConversion.
01309         msg = self._factory()
01310         for class_ in (mailbox.Message, mailbox.MaildirMessage,
01311                        mailbox.mboxMessage, mailbox.MHMessage,
01312                        mailbox.BabylMessage, mailbox.MMDFMessage):
01313             other_msg = class_()
01314             msg._explain_to(other_msg)
01315         other_msg = email.message.Message()
01316         self.assertRaises(TypeError, lambda: msg._explain_to(other_msg))

Here is the call graph for this function:

Definition at line 1294 of file test_mailbox.py.

01294 
01295     def test_initialize_incorrectly(self):
01296         # Initialize with invalid argument
01297         self.assertRaises(TypeError, lambda: self._factory(object()))

Here is the call graph for this function:

Definition at line 1274 of file test_mailbox.py.

01274 
01275     def test_initialize_with_binary_file(self):
01276         # Initialize based on contents of binary file
01277         with open(self._path, 'wb+') as f:
01278             f.write(_bytes_sample_message)
01279             f.seek(0)
01280             msg = self._factory(f)
01281             self._post_initialize_hook(msg)
01282             self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1252 of file test_mailbox.py.

01252 
01253     def test_initialize_with_eMM(self):
01254         # Initialize based on email.message.Message instance
01255         eMM = email.message_from_string(_sample_message)
01256         msg = self._factory(eMM)
01257         self._post_initialize_hook(msg)
01258         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1265 of file test_mailbox.py.

01265 
01266     def test_initialize_with_file(self):
01267         # Initialize based on contents of file
01268         with open(self._path, 'w+') as f:
01269             f.write(_sample_message)
01270             f.seek(0)
01271             msg = self._factory(f)
01272             self._post_initialize_hook(msg)
01273             self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1283 of file test_mailbox.py.

01283 
01284     def test_initialize_with_nothing(self):
01285         # Initialize without arguments
01286         msg = self._factory()
01287         self._post_initialize_hook(msg)
01288         self.assertIsInstance(msg, email.message.Message)
01289         self.assertIsInstance(msg, mailbox.Message)
01290         self.assertIsInstance(msg, self._factory)
01291         self.assertEqual(msg.keys(), [])
01292         self.assertFalse(msg.is_multipart())
01293         self.assertEqual(msg.get_payload(), None)

Here is the call graph for this function:

Definition at line 1259 of file test_mailbox.py.

01259 
01260     def test_initialize_with_string(self):
01261         # Initialize based on string
01262         msg = self._factory(_sample_message)
01263         self._post_initialize_hook(msg)
01264         self._check_sample(msg)

Here is the call graph for this function:

Definition at line 1486 of file test_mailbox.py.

01486 
01487     def test_labels(self):
01488         # Get, set, join, and leave labels
01489         msg = mailbox.BabylMessage(_sample_message)
01490         self.assertEqual(msg.get_labels(), [])
01491         msg.set_labels(['foobar'])
01492         self.assertEqual(msg.get_labels(), ['foobar'])
01493         msg.set_labels([])
01494         self.assertEqual(msg.get_labels(), [])
01495         msg.add_label('filed')
01496         self.assertEqual(msg.get_labels(), ['filed'])
01497         msg.add_label('resent')
01498         self.assertEqual(msg.get_labels(), ['filed', 'resent'])
01499         msg.add_label('resent')
01500         self.assertEqual(msg.get_labels(), ['filed', 'resent'])
01501         msg.remove_label('filed')
01502         self.assertEqual(msg.get_labels(), ['resent'])
01503         msg.add_label('foobar')
01504         self.assertEqual(msg.get_labels(), ['resent', 'foobar'])
01505         msg.remove_label('unseen')
01506         self.assertEqual(msg.get_labels(), ['resent', 'foobar'])
01507         msg.set_labels(['foobar', 'answered'])
01508         self.assertEqual(msg.get_labels(), ['foobar', 'answered'])

Here is the call graph for this function:

Definition at line 1509 of file test_mailbox.py.

01509 
01510     def test_visible(self):
01511         # Get, set, and update visible headers
01512         msg = mailbox.BabylMessage(_sample_message)
01513         visible = msg.get_visible()
01514         self.assertEqual(visible.keys(), [])
01515         self.assertIs(visible.get_payload(), None)
01516         visible['User-Agent'] = 'FooBar 1.0'
01517         visible['X-Whatever'] = 'Blah'
01518         self.assertEqual(msg.get_visible().keys(), [])
01519         msg.set_visible(visible)
01520         visible = msg.get_visible()
01521         self.assertTrue(visible.keys() == ['User-Agent', 'X-Whatever'])
01522         self.assertTrue(visible['User-Agent'] == 'FooBar 1.0')
01523         self.assertEqual(visible['X-Whatever'], 'Blah')
01524         self.assertIs(visible.get_payload(), None)
01525         msg.update_visible()
01526         self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever'])
01527         self.assertIs(visible.get_payload(), None)
01528         visible = msg.get_visible()
01529         self.assertEqual(visible.keys(), ['User-Agent', 'Date', 'From', 'To',
01530                                           'Subject'])
01531         for header in ('User-Agent', 'Date', 'From', 'To', 'Subject'):
01532             self.assertEqual(visible[header], msg[header])
01533 

Here is the call graph for this function:


Member Data Documentation

Reimplemented from test.test_mailbox.TestMessage.

Definition at line 1481 of file test_mailbox.py.


The documentation for this class was generated from the following file: