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)
Пример #2
0
 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)
     self.assertIsNotNone(put_result.extended_attribute)
     self.assertEqual('Text3', put_result.extended_attribute.field_name)
     self.assertEqual('New Field', put_result.extended_attribute.alias)
     self.assertEqual('188743737', put_result.extended_attribute.field_id)
     added_attribute_index = put_result.extended_attribute.index
     get_request = GetExtendedAttributeByIndexRequest(
         filename, added_attribute_index)
     get_result = self.tasks_api.get_extended_attribute_by_index(
         get_request)
     self.assertIsNotNone(get_result)
     self.assertIsInstance(get_result, ExtendedAttributeResponse)
     self.assertIsNotNone(get_result.extended_attribute)
     self.assertEqual('Text3', get_result.extended_attribute.field_name)
     self.assertEqual('New Field', get_result.extended_attribute.alias)
     self.assertEqual('188743737', get_result.extended_attribute.field_id)
     self.assertEqual(CustomFieldType.TEXT,
                      get_result.extended_attribute.cf_type)
     self.assertEqual(2, len(get_result.extended_attribute.value_list))
     self.assertEqual(111, get_result.extended_attribute.value_list[0].id)
     self.assertEqual('Internal',
                      get_result.extended_attribute.value_list[0].val)
     self.assertEqual(
         'descr1', get_result.extended_attribute.value_list[0].description)
     self.assertEqual(112, get_result.extended_attribute.value_list[1].id)
     self.assertEqual('External',
                      get_result.extended_attribute.value_list[1].val)
     self.assertEqual(
         'descr2', get_result.extended_attribute.value_list[1].description)
    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)