~exarkun/divmod.org/pop3-grabber-deletes

« back to all changes in this revision

Viewing changes to Quotient/xquotient/test/historic/test_pop3uid1to2.py

  • Committer: Jean-Paul Calderone
  • Date: 2012-10-31 21:09:10 UTC
  • Revision ID: exarkun@twistedmatrix.com-20121031210910-twws6d8lx3jy9k1v
Upgrader for old POP3UID items.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
"""
 
3
Test that a version 1 POP3UID is unchanged by the upgrade except that it gains a
 
4
value for the new C{retrieved} attribute set to something near the current time.
 
5
"""
 
6
 
 
7
from epsilon.extime import Time
 
8
 
 
9
from axiom.userbase import LoginSystem
 
10
from axiom.test.historic.stubloader import StubbedTest
 
11
 
 
12
from xquotient.test.historic.stub_pop3uid1to2 import VALUE, FAILED, GRABBER_ID
 
13
from xquotient.grabber import POP3UID
 
14
 
 
15
class POP3UIDUpgradeTestCase(StubbedTest):
 
16
    def test_attributes(self):
 
17
        loginSystem = self.store.findUnique(LoginSystem)
 
18
        account = loginSystem.accountByAddress(u'testuser', u'localhost')
 
19
        subStore = account.avatars.open()
 
20
 
 
21
        d = subStore.whenFullyUpgraded()
 
22
        def upgraded(ignored):
 
23
            [pop3uid] = list(subStore.query(POP3UID))
 
24
            self.assertEqual(VALUE, pop3uid.value)
 
25
            self.assertEqual(FAILED, pop3uid.failed)
 
26
            self.assertEqual(GRABBER_ID, pop3uid.grabberID)
 
27
 
 
28
            # This will be close enough.
 
29
            elapsed = (Time() - pop3uid.retrieved).total_seconds()
 
30
            self.assertTrue(abs(elapsed) < 60)
 
31
        d.addCallback(upgraded)
 
32
        return d