예제 #1
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])
예제 #2
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))
예제 #3
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())))
예제 #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())))
예제 #5
0
 def test_verify_interface(self):
     # Make sure that the object actually implements the interface.
     box = DirectoryMailBox(self.email_dir)
     verifyObject(IMailBox, box)
예제 #6
0
def directorymailBoxHandler(_context, directory):
    """Create the DirectoryMailBox and register the utility."""
    utility(_context, IMailBox, component=DirectoryMailBox(directory))