~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/mail/tests/test_helpers.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-13 01:11:42 UTC
  • mfrom: (13668.1.31 private-bug-0)
  • Revision ID: launchpad@pqm.canonical.com-20110813011142-b8xvpxhdja422ln2
[rs=sinzui][no-qa] Moved canonical.launchpad.mail to lp.services.mail,
 bugs.mail, code.mail.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
__metaclass__ = type
12
12
    directlyProvides,
13
13
    )
14
14
 
15
 
from canonical.launchpad.interfaces.mail import (
16
 
    EmailProcessingError,
17
 
    IWeaklyAuthenticatedPrincipal,
18
 
    )
19
 
from canonical.launchpad.mail.helpers import (
 
15
from canonical.launchpad.webapp.interaction import get_current_principal
 
16
from canonical.testing.layers import DatabaseFunctionalLayer
 
17
from lp.services.mail.helpers import (
20
18
    ensure_not_weakly_authenticated,
21
19
    ensure_sane_signature_timestamp,
22
20
    get_person_or_team,
23
21
    IncomingEmailError,
24
22
    parse_commands,
25
23
    )
26
 
from canonical.launchpad.webapp.interaction import get_current_principal
27
 
from canonical.testing.layers import DatabaseFunctionalLayer
 
24
from lp.services.mail.interfaces import (
 
25
    EmailProcessingError,
 
26
    IWeaklyAuthenticatedPrincipal,
 
27
    )
28
28
from lp.testing import (
29
29
    login_person,
30
30
    TestCase,
100
100
        one_week = 60 * 60 * 24 * 7
101
101
        self.assertRaises(
102
102
            IncomingEmailError, ensure_sane_signature_timestamp,
103
 
            now-one_week, 'bug report')
 
103
            now - one_week, 'bug report')
104
104
 
105
105
    def test_future_timestamp(self):
106
106
        # signature timestamps shouldn't be (far) in the future
108
108
        one_week = 60 * 60 * 24 * 7
109
109
        self.assertRaises(
110
110
            IncomingEmailError, ensure_sane_signature_timestamp,
111
 
            now+one_week, 'bug report')
 
111
            now + one_week, 'bug report')
112
112
 
113
113
    def test_near_future_timestamp(self):
114
114
        # signature timestamps in the near future are OK
115
115
        now = time.time()
116
116
        one_minute = 60
117
117
        # this should not raise an exception
118
 
        ensure_sane_signature_timestamp(now+one_minute, 'bug report')
 
118
        ensure_sane_signature_timestamp(now + one_minute, 'bug report')
119
119
 
120
120
    def test_recent_timestamp(self):
121
121
        # signature timestamps in the recent past are OK
122
122
        now = time.time()
123
123
        one_hour = 60 * 60
124
124
        # this should not raise an exception
125
 
        ensure_sane_signature_timestamp(now-one_hour, 'bug report')
 
125
        ensure_sane_signature_timestamp(now - one_hour, 'bug report')
126
126
 
127
127
 
128
128
class TestEnsureNotWeaklyAuthenticated(TestCaseWithFactory):
223
223
 
224
224
 
225
225
def test_suite():
226
 
    suite = DocTestSuite('canonical.launchpad.mail.helpers')
 
226
    suite = DocTestSuite('lp.services.mail.helpers')
227
227
    suite.addTests(unittest.TestLoader().loadTestsFromName(__name__))
228
228
    return suite