def test_task_privileges(self, mock_conn): task = Task(mock_conn, "task-name") task.allow_credentials_to_be_exported_to_task_environment() assert task.privileges is not None assert task.privileges._exportApiAndStorageCredentialsInEnvironment == True json_task = task._to_json() assert json_task['privileges'] is not None assert json_task['privileges']['exportApiAndStorageCredentialsInEnvironment'] is True # fields that need to be non null for the deserialization to not fail json_task['creationDate'] = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ") json_task['uuid'] = str(uuid.uuid4()) json_task['state'] = 'Submitted' json_task['runningCoreCount'] = 0 json_task['runningInstanceCount'] = 0 pool_from_json = Task(mock_conn, "task-name") pool_from_json._update(json_task) assert pool_from_json.privileges is not None assert pool_from_json.privileges._exportApiAndStorageCredentialsInEnvironment is True
def test_task_property_send_to_json_representation(self, mock_conn, property_name, expected_value): task = Task(mock_conn, "task-name") task._update(default_json_task) task_json = task._to_json() assert task_json[property_name] == expected_value
def test_task_property_update_value(self, mock_conn, property_name, expected_value): task = Task(mock_conn, "task-name") task._update(default_json_task) assert getattr(task, property_name) == expected_value
def test_execution_attempt_count_in_completed_instances(self, mock_conn): task = Task(mock_conn, "task-name") task._update(default_json_task) assert task.completed_instances[0].execution_attempt_count == 43
def test_execution_attempt_count_in_running_instances(self, mock_conn): task = Task(mock_conn, "task-name") task._update(task_with_running_instances) assert len(task.status.running_instances_info.per_running_instance_info) == 2 assert task.status.running_instances_info.per_running_instance_info[0].execution_attempt_count == 1 assert task.status.running_instances_info.per_running_instance_info[1].execution_attempt_count == 2