def test_check_recent_tasks_none(self): post = {} post['indicator'] = self.indicator post['record_type'] = "Search" form = SubmissionForm(post) # Required for normalizing form data in Django. form.is_valid() recent_tasks = form.check_recent_tasks(time_jump(hours=-24)) self.assertIsNone(recent_tasks)
def test_check_recent_tasks_one(self): post = {} post['indicator'] = self.indicator post['record_type'] = "Search" form = SubmissionForm(post) time = datetime.datetime.utcnow() # Required for normalizing form data in Django. form.is_valid() # Create the task and the TaskTracker. form.create_new_task(time) lookup = form.check_recent_tasks(time) self.assertIsNotNone(lookup)
def test_check_recent_tasks_many(self): post = {} post['indicator'] = self.indicator post['record_type'] = "Search" form = SubmissionForm(post) time_old = datetime.datetime.utcnow() time_new = datetime.datetime.utcnow() # Required for normalizing form data in Django. form.is_valid() # Create the task and the TaskTracker. form.create_new_task(time_old) form.create_new_task(time_new) # Request tasks in the last 24 hours. lookup = form.check_recent_tasks(time_jump(hours=-24)) self.assertIsNotNone(lookup) self.assertEquals(lookup.date, time_new)