Ejemplo n.º 1
0
    def db(self, maildir, notmuch):
        """Return a read-only notmuch2.Database.

        The database will have 3 messages, 2 threads.
        """
        msgid, _ = maildir.deliver(body='foo')
        maildir.deliver(body='bar')
        maildir.deliver(body='baz',
                        headers=[('In-Reply-To', '<{}>'.format(msgid))])
        notmuch('new')
        with dbmod.Database(maildir.path, 'rw') as db:
            yield db
Ejemplo n.º 2
0
 def test_to_maildir_flags(self, maildir, notmuch):
     _, pathname = maildir.deliver(flagged=True)
     notmuch('new')
     with database.Database(maildir.path,
                            mode=database.Mode.READ_WRITE) as db:
         msg = db.get(pathname)
         flags = msg.path.name.split(',')[-1]
         assert 'F' in flags
         msg.tags.discard('flagged')
         msg.tags.to_maildir_flags()
         flags = msg.path.name.split(',')[-1]
         assert 'F' not in flags
Ejemplo n.º 3
0
    def tagset(self, maildir, notmuch):
        """An non-empty mutable tagset.

        This will have the default new mail tags: inbox, unread.
        """
        _, pathname = maildir.deliver()
        notmuch('new')
        with database.Database(maildir.path,
                               mode=database.Mode.READ_WRITE,
                               config=database.Database.CONFIG.EMPTY) as db:
            msg = db.get(pathname)
            yield msg.tags
Ejemplo n.º 4
0
 def test_set_get(self, maildir):
     # Ensure get-set works from different db objects
     with dbmod.Database.create(maildir.path) as db0:
         db0.config['spam'] = 'ham'
     with dbmod.Database(maildir.path) as db1:
         assert db1.config['spam'] == 'ham'
Ejemplo n.º 5
0
 def test_neq(self, tagset, maildir, notmuch):
     notmuch('tag', '+foo', '*')
     with database.Database(maildir.path) as db:
         assert tagset != db.tags
Ejemplo n.º 6
0
 def test_hash(self, tagset, maildir, notmuch):
     h0 = hash(tagset)
     notmuch('tag', '+foo', '*')
     with database.Database(maildir.path) as db:
         h1 = hash(db.tags)
     assert h0 != h1
Ejemplo n.º 7
0
 def test_neq(self, tagset, maildir, notmuch):
     notmuch('tag', '+foo', '*')
     with database.Database(maildir.path,
                            config=database.Database.CONFIG.EMPTY) as db:
         assert tagset != db.tags