Ejemplo n.º 1
0
 def test_deleting_while_iterating(self):
     # Deleting while iterating through should be fine.
     self._add_mailfile('foo', 'This is the content')
     self._add_mailfile('bar', 'More content')
     self._add_mailfile('baz', 'More content')
     box = DirectoryMailBox(self.email_dir)
     for id, content in box.items():
         box.delete(id)
     self.assertEqual(0, len(list(box.items())))
Ejemplo n.º 2
0
 def test_items(self):
     # The items generator provides  the filename and content.
     self._add_mailfile('foo', 'This is the content')
     box = DirectoryMailBox(self.email_dir)
     [mail] = list(box.items())
     self.assertEqual('foo', os.path.basename(mail[0]))
     self.assertEqual('This is the content', mail[1])
Ejemplo n.º 3
0
 def test_delete(self):
     # Deleting the item removes the file from the mail dir.
     self._add_mailfile('foo', 'This is the content')
     self._add_mailfile('bar', 'More content')
     box = DirectoryMailBox(self.email_dir)
     box.delete(os.path.join(self.email_dir, 'foo'))
     items = list(box.items())
     self.assertEqual(1, len(items))
Ejemplo n.º 4
0
 def test_initially_empty(self):
     # Since the new directory has no files, the box is empty.
     box = DirectoryMailBox(self.email_dir)
     self.assertEqual(0, len(list(box.items())))