def test_get_taskmanagers_not_exist(datasource): # noqa: F811 """Do I error out when asking for garbage""" last_year = str(datetime.datetime.now() - datetime.timedelta(days=365)) two_years_future = str(datetime.datetime.now() + datetime.timedelta(days=730)) result = datasource.get_taskmanagers(taskmanager_name="no_such_task_manager") assert result == [] result = datasource.get_taskmanagers(start_time=two_years_future) assert result == [] result = datasource.get_taskmanagers(end_time=last_year, start_time=two_years_future) assert result == []
def test_get_taskmanagers(datasource): # noqa: F811 """Can I get multimple task managers""" yesterday = str(datetime.datetime.now() - datetime.timedelta(days=1)) two_years_future = str(datetime.datetime.now() + datetime.timedelta(days=730)) result0 = datasource.get_taskmanagers() assert len(result0) == 2 result1 = datasource.get_taskmanagers(taskmanager_name="taskmanager1") assert len(result1) == 1 assert result1[0]["name"] == "taskmanager1" assert str( result1[0]["taskmanager_id"]) == "11111111-1111-1111-1111-111111111111" result2 = datasource.get_taskmanagers(start_time=yesterday) assert len(result2) == 1 assert result2[0]["name"] == "taskmanager2" assert str( result2[0]["taskmanager_id"]) == "22222222-2222-2222-2222-222222222222" result3 = datasource.get_taskmanagers(end_time=yesterday) assert len(result3) == 1 assert result3[0]["name"] == "taskmanager1" assert str( result3[0]["taskmanager_id"]) == "11111111-1111-1111-1111-111111111111" result4 = datasource.get_taskmanagers(taskmanager_name="taskmanager1", end_time=yesterday) assert len(result4) == 1 assert result4[0]["name"] == "taskmanager1" assert str( result4[0]["taskmanager_id"]) == "11111111-1111-1111-1111-111111111111" result5 = datasource.get_taskmanagers(taskmanager_name="taskmanager2", start_time=yesterday) assert len(result5) == 1 assert result5[0]["name"] == "taskmanager2" assert str( result5[0]["taskmanager_id"]) == "22222222-2222-2222-2222-222222222222" result6 = datasource.get_taskmanagers(taskmanager_name="taskmanager2", start_time=yesterday, end_time=two_years_future) assert len(result6) == 1 assert result6[0]["name"] == "taskmanager2" assert str( result6[0]["taskmanager_id"]) == "22222222-2222-2222-2222-222222222222" result7 = datasource.get_taskmanagers(start_time=yesterday, end_time=two_years_future) assert len(result7) == 1 assert result7[0]["name"] == "taskmanager2" assert str( result7[0]["taskmanager_id"]) == "22222222-2222-2222-2222-222222222222"