Пример #1
0
    def setup_unit_and_followers(self, confirmed=True):
        self.unit = models.Unit.objects.create(id='E25')

        self.phone_follower = any_user(id=1, email='*****@*****.**')
        models.update(self.phone_follower.profile, phone='phone_follower #',
                      phone_confirmed=confirmed)
        models.UnitFollower.objects.create(
            unit=self.unit, user=self.phone_follower, by_phone=True)

        self.email_follower = any_user(id=2, email='*****@*****.**')
        models.update(self.email_follower.profile, phone='email_follower #',
                      email_confirmed=confirmed)
        models.UnitFollower.objects.create(
            unit=self.unit, user=self.email_follower, by_email=True)

        self.both_follower = any_user(id=3, email='*****@*****.**')
        models.update(self.both_follower.profile, phone='both_follower #',
                      email_confirmed=confirmed, phone_confirmed=confirmed)
        models.UnitFollower.objects.create(
            unit=self.unit, user=self.both_follower,
            by_email=True, by_phone=True)

        self.neither_follower = any_user(id=4, email='*****@*****.**')
        models.update(self.neither_follower.profile,
                      phone='neither_follower #')
        models.UnitFollower.objects.create(
            unit=self.unit, user=self.neither_follower,
            by_email=False, by_phone=False)
Пример #2
0
 def test_save_latest_if_duplicate_phone(self):
     user1 = any_user(id=1)
     utils.update(user1.profile, phone='555-555-5555')
     user2 = any_user(id=2)
     utils.update(user2.profile, phone='555-555-5555')
     verification = models.PhoneVerification.objects.create(
         code='42', sent_at=datetime.now(), value='555-555-5555')
     form = forms.VerifyPhoneForm({'code': '42'})
     self.assertTrue(form.is_valid())
     saved_user = form.save()
     self.assertEqual(saved_user, user2)
     self.assertTrue(saved_user.profile.phone_confirmed)
     self.assertEqual(
         models.Profile.objects.filter(phone_confirmed=True).count(), 1)
Пример #3
0
    def setUp(self):
        self.resource = any_model(SimpleResource)

        # pass specific datetimes to any_user because it's not yet timezone-aware - works around RuntimeWarnings
        self.user = any_user(date_joined=timezone.now(), last_login=timezone.now())
Пример #4
0
    def setUp(self):
        self.resource = any_model(SimpleResource)

        # pass specific datetimes to any_user because it's not yet timezone-aware - works around RuntimeWarnings
        self.user = any_user(date_joined=timezone.now(),
                             last_login=timezone.now())