unittest_notifications.py 1.12 KB
Newer Older
1
2
3
4
from datetime import date

from logilab.common.testlib import unittest_main

5
from cubicweb.devtools.testlib import MAILBOX, CubicWebTC
6
7
from cubicweb.devtools.fake import FakeConfig
from cubicweb.web.request import CubicWebRequestBase
8
9
10
11

class ForgotTC(CubicWebTC):

    def setup_database(self):
12
13
14
15
16
17
18
        with self.admin_access.repo_cnx() as cnx:
            for index in xrange(4):
                user = self.create_user(cnx, u'test_user%s' % index)
                cnx.create_entity('EmailAddress',
                                  address=u'test_user%s@logilab.fr' % index,
                                  reverse_use_email=user)
            cnx.commit()
19
20
21
22

    def test_reset_password(self):
        MAILBOX[:] = []
        self.assertEqual(len(MAILBOX), 0)
23
        self.config.global_set_option('base-url', 'http://babar.com/')
24
        with self.repo.internal_cnx() as cnx:
25
            cnx.call_service('forgotpwd_send_email', use_email=u'test_user1@logilab.fr')
26
            cnx.commit()
27
        self.assertEqual(len(MAILBOX), 1)
28
        self.assertIn('http://babar.com', MAILBOX[0].content)
29
30


31
32
33
34
if __name__ == '__main__':
    unittest_main()


35