Ticket #1977: ticket1977_unittest.diff

File ticket1977_unittest.diff, 1.4 KB (added by tvachon, 10 years ago)

Unittest for this defect

  • test_imap.py

    old new  
    22292229    def testFetchFastUID(self):
    22302230        return self.testFetchFast(1)
    22312231
     2232class DefaultSearchTestCase(IMAP4HelperMixin, unittest.TestCase):
     2233    def setUp(self):
     2234        self.server = imap4.IMAP4Server()
     2235        self.server.state = 'select'
     2236        self.server.mbox = self
     2237        self.connected = defer.Deferred()
     2238        self.client = SimpleClient(self.connected)
     2239        self.msgObjs = [
     2240            FakeyMessage({}, (), '', '', 12345, None),
     2241            FakeyMessage({}, (), '', '', 999, None),
     2242            FakeyMessage({}, (), '', '', 10101, None),
     2243        ]
     2244
     2245    def fetch(self, messages, uid):
     2246        self.received_messages = messages
     2247        self.received_uid = uid
     2248        return iter(zip(range(len(self.msgObjs)), self.msgObjs))
     2249
     2250    def testDefaultSearchUnexpected(self):
     2251
     2252        def login():
     2253            return self.client.login('testuser', 'password-test')
     2254        def select():
     2255            return self.client.select('mailbox-test')
     2256        def search():
     2257            return self.client.search('1',"UNDELETED","UNSEEN")
     2258
     2259        d = self.connected.addCallback(strip(search))
     2260        d.addCallback(self._cbStopClient)
     2261        d.addErrback(self._ebGeneral)
     2262        self.loopback()
    22322263
    22332264class FetchSearchStoreTestCase(unittest.TestCase, IMAP4HelperMixin):
    22342265    implements(imap4.ISearchableMailbox)