def redeem_invite(self, invite, email): """Given an invite_url go to it and redeem an invite.""" # Lets make sure we have a clean slate self.client.logout() assert not User.objects.filter(email=email), ( "User shouldn't be in database.") # We need to store the invite code in the session self.client.get(invite.get_url(), follow=True) # BrowserID needs an assertion not to be whiney d = dict(assertion=self.fake_assertion) with mock_browserid(email): self.client.post(reverse('browserid_login'), d, follow=True) # Now let's register d = dict(full_name='Desaaaaaaai', username='******', country='pl', optin=True) with mock_browserid(email): self.client.post(reverse('users:register'), d, follow=True) # Return the New Users Profile invited_user_profile = User.objects.get(email=email).get_profile() return invited_user_profile
def invite_someone(self, email, invite_message): """This method will invite a user. This will verify that an email with link has been sent. """ # login as fake user. d = dict(assertion=self.fake_assertion) with mock_browserid(self.fake_email3): self.client.post(reverse('browserid_login'), d, follow=True) # Send an invite. url = reverse('invite') d = dict(recipient=email, message=invite_message) r = self.mozillian_client.post(url, d, follow=True) eq_(r.status_code, 200) assert ('%s has been invited to Mozillians.' % email in r.content) # See that the email was sent. eq_(len(mail.outbox), 1) i = Invite.objects.get() invite_url = i.get_url() assert settings.FROM_NOREPLY in mail.outbox[0].from_email assert invite_url in mail.outbox[0].body, "No link in email." return i
def invite_without_message(self, email): """ Make sure we can send an invite without the optional personal message and that the template doesn't use Personal message: when there's no personal message. """ #login as fake user. d = dict(assertion=self.fake_assertion) with mock_browserid(self.fake_email3): self.client.post(reverse('browserid_login'), d, follow=True) # Send an invite without a personal message. url = reverse('invite') d = dict(recipient=email) r = self.mozillian_client.post(url, d, follow=True) eq_(r.status_code, 200) assert ('%s has been invited to Mozillians.' % email in r.content) # See that the email was sent. eq_(len(mail.outbox), 2) # Note it's mail.outbox[1] here because we're sending another # message in a previous test. assert not ("Personal message" in mail.outbox[1].body)