

def test_messages(self):
    db = mock_db()
    account = _account_for_test(db=db)
    msg4_data = (4, set(['\\Seen']), 'Subject: test message')
    msg22_data = (22, set(['\\Seen', '\\Answered']), 'Subject: blah')
    with mock_worker(myfolder={
        4: msg4_data,
        22: msg22_data,
    }) as worker:
        account.perform_update()
    account2 = _account_for_test(db=db)
    myfolder = account2.get_folder('myfolder')
    messages = list(myfolder.list_messages())
    messages.sort(key=(lambda m: m.uid))
    self.assertEqual(len(messages), 2)
    (msg4, msg22) = messages
    self.assertEqual(msg4.uid, 4)
    self.assertEqual(msg4.flags, set(['\\Seen']))
    self.assertEqual(msg4.raw_headers, 'Subject: test message')
    self.assertEqual(msg22.uid, 22)
    self.assertEqual(msg22.flags, set(['\\Seen', '\\Answered']))
    self.assertEqual(msg22.raw_headers, 'Subject: blah')

dataset/ETHPy150Open mgax/tinymail/src/tinymail/tests/test_account.py PersistenceTest.test_messages/original