Exemplo n.º 1
0
 def test_dont_update_old_dibs(self): 
     
     dibs = Dibs()
     dibs.club = self.c
     dibs.user_profile = self.u1.get_profile()
     dibs.race_class = self.race_class
     dibs.number = 3
     dibs.duration = 30
     dibs.expires = self.today-datetime.timedelta(days=5)
     dibs.save()
     dibs.created = self.today-datetime.timedelta(days=60)
     dibs.save()
     
     self.c.assign_dibs()  
     
     dibs = Dibs.objects.filter(user_profile=self.u1.get_profile()).get()
     
     self.assertEqual(dibs.expires, self.today-datetime.timedelta(days=5))
     self.assertEqual(dibs.duration, 30)
Exemplo n.º 2
0
 def test_update_existing_dibs(self):
     
     dibs = Dibs()
     dibs.club = self.c
     dibs.user_profile = self.u3.get_profile()
     dibs.race_class = self.race_class
     dibs.number = 3
     dibs.duration = 30
     dibs.expires = self.today+datetime.timedelta(days=5)
     dibs.save()
     dibs.created = self.today-datetime.timedelta(days=60)
     dibs.save()
     
     self.c.assign_dibs()       
     self.assertEqual(len(self.c.dibs.filter(club=self.c, user_profile=self.u3.get_profile()).all()), 1) 
     dibs = Dibs.objects.filter(club=self.c, user_profile=self.u3.get_profile()).get()
     self.assertEqual(dibs.duration, 60)
     self.assertEqual(dibs.expires, self.e3.date+datetime.timedelta(days=60))
     
     dibs.delete()
Exemplo n.º 3
0
    def test_clean_dibs(self): 
        
        dibs = Dibs()
        dibs.club = self.c
        dibs.expires = datetime.date.today()-datetime.timedelta(days=10)
        dibs.duration = 30
        dibs.number = 99
        dibs.race_class = self.race_class
        dibs.user_profile = self.u2.get_profile()
        
        dibs.save()

        clean_dibs()
        
        self.assertEqual(len(self.c.dibs.filter(club=self.c, user_profile=self.u3.get_profile()).all()), 1) 
        dibs = Dibs.objects.filter(club=self.c, user_profile=self.u3.get_profile()).get()
        self.assertEqual(dibs.number, 3)
        self.assertEqual(dibs.race_class, self.race_class)
        self.assertEqual(dibs.expires, self.e4.date+datetime.timedelta(days=30))
        
        self.assertEqual(len(self.c.dibs.filter(club=self.c, user_profile=self.u2.get_profile()).all()), 0)