def test_updates_only_fist_one(self): time_1 = timezone.now() - datetime.timedelta(days=1) time_2 = time_1 + datetime.timedelta(hours=1) time_3 = time_1 + datetime.timedelta(hours=2) time_4 = time_1 + datetime.timedelta(hours=3) project = RecruitProjectFactory() project.review_request_time = time_1 review_1 = RecruitProjectReviewFactory( recruit_project=project, timestamp=time_1, status=COMPETENT ) review_1.timestamp = time_2 review_1.save() review_2 = RecruitProjectReviewFactory( recruit_project=project, timestamp=time_3, status=COMPETENT ) review_2.timestamp = time_3 review_2.save() review_3 = RecruitProjectReviewFactory( recruit_project=project, timestamp=time_4, status=COMPETENT ) review_3.timestamp = time_4 review_3.trusted = True review_3.save() review_3.update_recent_validation_flags_for_project() review_1.refresh_from_db() review_2.refresh_from_db() review_3.refresh_from_db() self.assertEqual(review_1.validated, RecruitProjectReview.CORRECT) self.assertEqual(review_2.validated, None) self.assertEqual(review_3.validated, None)
def test_all(self): time_1 = timezone.now() - datetime.timedelta(days=1) time_2 = time_1 + datetime.timedelta(hours=1) time_3 = time_1 + datetime.timedelta(hours=2) time_4 = time_1 + datetime.timedelta(hours=3) project = RecruitProjectFactory() project.review_request_time = time_2 review_1 = RecruitProjectReviewFactory(recruit_project=project, timestamp=time_1) review_1.timestamp = time_1 review_1.save() review_2 = RecruitProjectReviewFactory(recruit_project=project, timestamp=time_3) review_2.timestamp = time_3 review_2.save() review_3 = RecruitProjectReviewFactory(recruit_project=project, timestamp=time_4) review_3.timestamp = time_4 review_3.save() # assert review_1.timestamp == time_1, review_1.timestamp # assert project.review_request_time == time_2 # assert review_2.timestamp == time_3 # assert review_3.timestamp == time_4 # assert time_1 < time_2 # assert time_2 < time_3 # assert time_3 < time_4 self.assertFalse(review_1.is_first_review_after_request()) self.assertTrue(review_2.is_first_review_after_request()) self.assertFalse(review_3.is_first_review_after_request())