def handle(self, *args, **options):
     if options['infinite']:
         while True:
             UserExamination.fixed_expired()
             time.sleep(60)
     else:
         UserExamination.fixed_expired()
示例#2
0
    def test_user_examination_fixed_expired(self):
        department = Department.objects.create(name='test dep')
        examination = Examination.objects.create(name='test exam', department=department)
        user = User.objects.create(username='******', email='*****@*****.**')
        department.employees.add(user)

        available_from = datetime.datetime.now() - datetime.timedelta(days=2)
        complete_until = datetime.datetime.now() - datetime.timedelta(days=1)
        user_examination = UserExamination.objects.create(
            examination=examination, user=user, available_from=available_from, complete_until=complete_until,
        )

        UserExamination.fixed_expired()

        self.assertIsNotNone(UserExamination.objects.get(id=user_examination.id).finished_at)