Example #1
0
    def test_new_user_email(self):
        """
        Testing sending an e-mail after a new user has successfully registered.
        """
        new_user_info = {
            'username': '******',
            'password1': 'password',
            'password2': 'password',
            'email': '*****@*****.**',
            'first_name': 'New',
            'last_name': 'User'
        }

        # Registration request have to be sent twice since djblets need to
        # validate cookies on the second request.
        self.client.get('/account/register/', new_user_info)
        self.client.post('/account/register/', new_user_info)

        siteconfig = SiteConfiguration.objects.get_current()
        admin_name = siteconfig.get('site_admin_name')
        admin_email_addr = siteconfig.get('site_admin_email')
        email = mail.outbox[0]

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(email.subject,
                         "New Review Board user registration for NewUser")

        self.assertEqual(email.from_email, self.sender)
        self.assertEqual(email.extra_headers['From'], settings.SERVER_EMAIL)
        self.assertEqual(email.to[0], build_email_address(admin_name,
                                                          admin_email_addr))
Example #2
0
    def test_new_user_email(self):
        """
        Testing sending an e-mail after a new user has successfully registered.
        """
        new_user_info = {
            'username': '******',
            'password1': 'password',
            'password2': 'password',
            'email': '*****@*****.**',
            'first_name': 'New',
            'last_name': 'User'
        }

        # Registration request have to be sent twice since djblets need to
        # validate cookies on the second request.
        self.client.get('/account/register/', new_user_info)
        self.client.post('/account/register/', new_user_info)

        siteconfig = SiteConfiguration.objects.get_current()
        admin_name = siteconfig.get('site_admin_name')
        admin_email_addr = siteconfig.get('site_admin_email')
        email = mail.outbox[0]

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(email.subject,
                         "New Review Board user registration for NewUser")

        self.assertEqual(email.from_email, self.sender)
        self.assertEqual(email.extra_headers['From'], settings.SERVER_EMAIL)
        self.assertEqual(email.to[0], build_email_address(admin_name,
                                                          admin_email_addr))
Example #3
0
    def test_new_user_email(self):
        """
        Testing sending an e-mail after a new user has successfully registered.
        """
        # Clear the outbox.
        mail.outbox = []

        new_user_info = {
            "username": "******",
            "password1": "password",
            "password2": "password",
            "email": "*****@*****.**",
            "first_name": "New",
            "last_name": "User",
        }

        # Registration request have to be sent twice since djblets need to
        # validate cookies on the second request.
        self.client.get("/account/register/", new_user_info)
        self.client.post("/account/register/", new_user_info)

        siteconfig = SiteConfiguration.objects.get_current()
        admin_name = siteconfig.get("site_admin_name")
        admin_email_addr = siteconfig.get("site_admin_email")
        email = mail.outbox[0]

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(email.subject, "New Review Board user registration for NewUser")

        self.assertEqual(email.from_email, self.sender)
        self.assertEqual(email.extra_headers["From"], settings.SERVER_EMAIL)
        self.assertEqual(email.to[0], build_email_address(admin_name, admin_email_addr))
Example #4
0
 def _get_sender(self, user):
     return build_email_address(user.get_full_name(), self.sender)
Example #5
0
 def _get_sender(self, user):
     return build_email_address(user.get_full_name(), self.sender)