def test_put_extended_attribute_fourth_case_with_uniform_flag_value(self): filename = 'NewProductDev.mpp' self.upload_file(filename) new_extended_attribute = ExtendedAttributeDefinition() new_extended_attribute.calculation_type = CalculationType.NONE new_extended_attribute.cf_type = CustomFieldType.FLAG new_extended_attribute.field_name = "Flag12" new_extended_attribute.element_type = ElementType.TASK new_extended_attribute.alias = "Custom Flag Field" put_request = PutExtendedAttributeRequest(new_extended_attribute, filename) put_result = self.tasks_api.put_extended_attribute(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, ExtendedAttributeItemResponse) get_request = GetTaskRequest(filename, 27) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) new_extended_attribute = ExtendedAttribute('188743973', flag_value=True) get_result.task.extended_attributes.append(new_extended_attribute) put_request = PutTaskRequest(filename, 27, get_result.task) put_result = self.tasks_api.put_task(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, TaskResponse) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) self.assertEqual(1, len(get_result.task.extended_attributes)) self.assertEqual('188743973', get_result.task.extended_attributes[0].field_id) self.assertTrue(get_result.task.extended_attributes[0].flag_value)
def test_put_task(self): filename = 'Project2016.mpp' self.upload_file(filename) get_request = GetTaskRequest(filename, 4) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) get_result.task.name = "Modified task name" get_result.task.is_manual = True get_result.task.manual_start = datetime(2015, 10, 1, 9, 15, 0) get_result.task.manual_finish = datetime(2015, 10, 1, 17, 15, 0) put_request = PutTaskRequest(filename, 4, get_result.task, CalculationMode.NONE, False) put_result = self.tasks_api.put_task(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, TaskResponse) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) self.assertIsNotNone(get_result.task) self.assertEqual('Modified task name', get_result.task.name) self.assertTrue(get_result.task.is_manual) self.assertEqual(datetime(2015, 10, 1, 9, 15, 0), get_result.task.manual_start) self.assertEqual(datetime(2015, 10, 1, 17, 15, 0), get_result.task.manual_finish)
def test_put_recalculate_project(self): filename = 'sample.mpp' self.upload_file(filename) post_task_request = PostTaskRequest(filename, 'NewTaskName') post_task_result = self.tasks_api.post_task(post_task_request) self.assertIsNotNone(post_task_result) self.assertIsInstance(post_task_result, TaskItemResponse) task_uid = post_task_result.task_item.uid get_task_request = GetTaskRequest(filename, task_uid) get_task_result = self.tasks_api.get_task(get_task_request) self.assertIsNotNone(get_task_result) self.assertIsInstance(get_task_result, TaskResponse) task = get_task_result.task task.name = 'New task Name' task.actual_start = datetime(2000, 10, 20, 8) task.actual_finish = datetime(2000, 10, 9, 18) task.cost = 100 put_task_request = PutTaskRequest(filename, task_uid, task, recalculate=False) put_task_result = self.tasks_api.put_task(put_task_request) self.assertIsNotNone(put_task_result) self.assertIsInstance(put_task_result, TaskResponse) put_recalculate_project_request = PutRecalculateProjectRequest( filename, CalculationMode.NONE, True) put_recalculate_project_result = self.tasks_api.put_recalculate_project( put_recalculate_project_request) self.assertIsNotNone(put_recalculate_project_result) self.assertIsInstance(put_recalculate_project_result, ProjectRecalculateResponse) self.assertEqual( ProjectValidationState.VALID, put_recalculate_project_result.result.validation_state)
def test_put_extended_attribute(self): filename = 'NewProductDev.mpp' self.upload_file(filename) first_value = Value() first_value.description = "descr1" first_value.val = "Internal" first_value.id = 111 second_value = Value() second_value.description = "descr2" second_value.val = "External" second_value.id = 112 new_extended_attribute = ExtendedAttributeDefinition() new_extended_attribute.calculation_type = CalculationType.LOOKUP new_extended_attribute.cf_type = CustomFieldType.TEXT new_extended_attribute.field_name = "Text3" new_extended_attribute.element_type = ElementType.TASK new_extended_attribute.alias = "New Field" new_extended_attribute.value_list = [first_value, second_value] put_request = PutExtendedAttributeRequest(new_extended_attribute, filename) put_result = self.tasks_api.put_extended_attribute(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, ExtendedAttributeItemResponse) get_request = GetTaskRequest(filename, 27) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) new_extended_attribute = ExtendedAttribute( put_result.extended_attribute.field_id, lookup_value_id=112) get_result.task.extended_attributes.append(new_extended_attribute) put_request = PutTaskRequest(filename, 27, get_result.task) put_result = self.tasks_api.put_task(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, TaskResponse) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) self.assertEqual('188743737', get_result.task.extended_attributes[0].field_id) self.assertEqual( 112, get_result.task.extended_attributes[0].lookup_value_id)
def test_put_extended_attribute_third_case_with_uniform_duration_value( self): filename = 'NewProductDev.mpp' self.upload_file(filename) new_extended_attribute = ExtendedAttributeDefinition() new_extended_attribute.calculation_type = CalculationType.NONE new_extended_attribute.cf_type = CustomFieldType.DURATION new_extended_attribute.field_name = "Duration3" new_extended_attribute.element_type = ElementType.TASK new_extended_attribute.alias = "Custom Duration Field" put_request = PutExtendedAttributeRequest(new_extended_attribute, filename) put_result = self.tasks_api.put_extended_attribute(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, ExtendedAttributeItemResponse) get_request = GetTaskRequest(filename, 27) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) duration = Duration() duration.time_span = '04:00:00' duration.time_unit = TimeUnitType.MINUTE new_extended_attribute = ExtendedAttribute('188743785', duration_value=duration) get_result.task.extended_attributes.append(new_extended_attribute) put_request = PutTaskRequest(filename, 27, get_result.task) put_result = self.tasks_api.put_task(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, TaskResponse) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) self.assertEqual(1, len(get_result.task.extended_attributes)) self.assertEqual('188743785', get_result.task.extended_attributes[0].field_id) self.assertIsNotNone( get_result.task.extended_attributes[0].duration_value) self.assertEqual( '04:00:00', get_result.task.extended_attributes[0].duration_value.time_span)
def test_put_extended_attribute_second_case_with_uniform_date_value(self): filename = 'NewProductDev.mpp' self.upload_file(filename) new_extended_attribute = ExtendedAttributeDefinition() new_extended_attribute.calculation_type = CalculationType.NONE new_extended_attribute.cf_type = CustomFieldType.FINISH new_extended_attribute.field_name = "Finish4" new_extended_attribute.element_type = ElementType.TASK new_extended_attribute.alias = "Custom Finish Field" put_request = PutExtendedAttributeRequest(new_extended_attribute, filename) put_result = self.tasks_api.put_extended_attribute(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, ExtendedAttributeItemResponse) get_request = GetTaskRequest(filename, 27) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) new_extended_attribute = ExtendedAttribute('188743742', date_value=datetime( 2018, 3, 4, 12, 30, 0)) get_result.task.extended_attributes.append(new_extended_attribute) put_request = PutTaskRequest(filename, 27, get_result.task) put_result = self.tasks_api.put_task(put_request) self.assertIsNotNone(put_result) self.assertIsInstance(put_result, TaskResponse) get_result = self.tasks_api.get_task(get_request) self.assertIsNotNone(get_result) self.assertIsInstance(get_result, TaskResponse) self.assertEqual(1, len(get_result.task.extended_attributes)) self.assertEqual('188743742', get_result.task.extended_attributes[0].field_id) self.assertEqual(datetime(2018, 3, 4, 12, 30, 0), get_result.task.extended_attributes[0].date_value)