def test_print_workstatus_old_task_subtasks(caplog): session = Session(load_questions=False) session.stale_timeout = 5 nowFunction = lambda tzinfo: datetime.datetime( 2017, 12, 20, 0, 0, 0, 0, tzinfo=tzinfo ) workStatus = "TEST" taskDetails = json.dumps( { "obtained": "2016-11-22 10:43:21 UTC", "batches": [ { "completed": 1, "description": "Fooing the bar", "size": 2, "startDate": "2016-11-22 10:43:22 UTC", } ], } ) _print_work_status_helper(session, workStatus, taskDetails, nowFunction) assert "status: TEST" in caplog.text assert ( ".... {obtained} Fooing the bar 1 / 2. (1y27d13:16:39 elapsed)".format( obtained=_print_timestamp( _parse_timestamp(json.loads(taskDetails)["obtained"]) ) ) in caplog.text )
def test_print_workstatus_fresh_task(caplog): session = Session(load_questions=False) session.stale_timeout = 5 nowFunction = lambda tzinfo: datetime.datetime( 2017, 12, 20, 0, 0, 0, 0, tzinfo=tzinfo ) workStatus = "TEST" taskDetails = json.dumps( { "obtained": "2017-12-20 00:00:00 UTC", "batches": [ { "completed": 0, "description": "Fooing the bar", "size": 0, "startDate": "2017-12-20 00:00:00 UTC", } ], } ) _print_work_status_helper(session, workStatus, taskDetails, nowFunction) assert "status: TEST" in caplog.text assert ( ".... {obtained} Fooing the bar".format( obtained=_print_timestamp( _parse_timestamp(json.loads(taskDetails)["obtained"]) ) ) in caplog.text )