def test_increment_retry_count_on_fail(self): """ On failed call to HTTP Endpoint, the service must increment retry_count on db the last_retry_date field should also be updated This test tests the setTaskSendAttemptAsFail function manually """ engine = create_engine('sqlite:///db/test.db', echo=False) tasks = TaskLogic(db_engine=engine) data_past = { "scheduled_time": datetime.utcnow() - timedelta(hours=1), "endpoint_url": "http://example.com", "endpoint_headers": { "Content-Length": 0 }, "endpoint_body": "Test Body", "endpoint_method": "POST", "max_retry_count": 5 } task_uuid = tasks.createTask( scheduled_time=data_past["scheduled_time"], endpoint_url=data_past["endpoint_url"], endpoint_headers=data_past["endpoint_headers"], endpoint_body=data_past["endpoint_body"], endpoint_method=data_past["endpoint_method"], max_retry_count=data_past["max_retry_count"]) tasks.setTaskSendAttemptAsFail(task_uuid) task_after = tasks.getTaskByUUID(task_uuid) self.assertEqual(task_after.retry_count, 1) self.assertIsInstance(task_after.last_retry_date, datetime) old_retry_date = task_after.last_retry_date tasks.setTaskSendAttemptAsFail(task_uuid) task_after2 = tasks.getTaskByUUID(task_uuid) self.assertEqual(task_after2.retry_count, 2) self.assertIsInstance(task_after2.last_retry_date, datetime) self.assertNotEqual(task_after2.last_retry_date, old_retry_date)