Пример #1
0
    def test_all_time(self):
        from models import UserStats, User
        import datetime

        from django.test import RequestFactory
        from django.core.urlresolvers import reverse
        from views import all_time_top_ten

        day = datetime.datetime(2017, 10, 20)

        for i in range(11):
            u = User(public_name='Roulio', email=str(i))
            u.save()
            s = UserStats(user=u, start_date=day)
            s.monday_steps = 10 + i
            s.save()
            s = UserStats(user=u, start_date=day - datetime.timedelta(days=7))
            s.monday_steps = 10 + i
            s.save()

        factory = RequestFactory()

        rq = factory.get(reverse('all_time_top_ten'))

        response = all_time_top_ten(rq)
        self.assertIsNotNone(response)
Пример #2
0
 def save(self):
     profile = UserProfile()
     stats = UserStats()
     stats.save()
     username = self.cleaned_data["username"]
     email = self.cleaned_data["email"]
     password = self.cleaned_data["password"]
     display_image = self.cleaned_data["display_image"]
     if display_image is None:
         admin = UserProfile.objects.get(id=1)
         display_image = admin.display_image
     profile.user = User.objects.create_user(username, email, password)
     profile.display_image = display_image
     profile.stats = stats
     profile.save()
Пример #3
0
 def save(self):
     profile = UserProfile()
     stats = UserStats()
     stats.save()
     username = self.cleaned_data["username"]
     email = self.cleaned_data["email"]
     password = self.cleaned_data["password"]
     display_image = self.cleaned_data["display_image"]
     if display_image is None:
         admin = UserProfile.objects.get(id=1)
         display_image = admin.display_image
     profile.user = User.objects.create_user(username, email, password)
     profile.display_image = display_image
     profile.stats = stats
     profile.save()