예제 #1
0
 def test_post_task_recurring_info(self):
     filename = 'sample.mpp'
     self.upload_file(filename)
     recurring_info = RecurringInfo()
     recurring_info.recurrence_pattern = RecurrencePattern.WEEKLY
     recurring_info.occurrences = 4
     recurring_info.weekly_repetitions = 3
     recurring_info.weekly_days = WeekDayType.THURSDAY
     recurring_info.start_date = datetime(2018, 1, 1, 8)
     recurring_info.end_date = datetime(2018, 12, 31)
     recurring_info.use_end_date = True
     post_request = PostTaskRecurringInfoRequest(filename, 0,
                                                 'New recurring task',
                                                 recurring_info, 'Standard')
     post_result = self.tasks_api.post_task_recurring_info(post_request)
     self.assertIsNotNone(post_result)
     self.assertIsInstance(post_result, TaskItemResponse)
     get_request = GetTaskRequest(filename, post_result.task_item.uid)
     get_result = self.tasks_api.get_task(get_request)
     self.assertIsNotNone(get_result)
     self.assertIsInstance(get_result, TaskResponse)
     self.assertEqual(18, len(get_result.task.subtasks_uids))
     task_uid = max(get_result.task.subtasks_uids)
     get_request = GetTaskRequest(filename, task_uid)
     get_result = self.tasks_api.get_task(get_request)
     self.assertIsNotNone(get_result)
     self.assertIsInstance(get_result, TaskResponse)
     self.assertEqual(datetime(2018, 12, 27, 8, 0, 0),
                      get_result.task.start)
    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_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_post_tasks(self):
        filename = 'Home_move_plan.mpp'
        self.upload_file(filename)
        first_task_create_request = TaskCreationRequest(
            task_name="SomeFirstTaskName")
        second_task_create_request = TaskCreationRequest(
            task_name="SomeSecondTaskNameWithParent", parent_task_uid=2)
        post_request = PostTasksRequest(
            filename, [first_task_create_request, second_task_create_request])
        post_result = self.tasks_api.post_tasks(post_request)
        self.assertIsNotNone(post_result)
        self.assertIsInstance(post_result, TaskItemsResponse)
        self.assertIsNotNone(post_result.tasks)
        self.assertEqual(len(post_request.requests),
                         len(post_result.tasks.task_item))
        newSubtaskUid = [
            t.uid for t in post_result.tasks.task_item
            if t.name == second_task_create_request.task_name
        ][0]

        get_request = GetTaskRequest(
            filename, second_task_create_request.parent_task_uid)
        get_result = self.tasks_api.get_task(get_request)
        self.assertIsNotNone(get_result)
        self.assertIsInstance(get_result, TaskResponse)
        self.assertIsNotNone(get_result.task)
        self.assertIn(newSubtaskUid, get_result.task.subtasks_uids)
 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_move_task_to_sibling(self):
        filename = 'NewProductDev.mpp'
        self.upload_file(filename)
        put_request = PutMoveTaskToSiblingRequest(filename, 40, 41)
        put_result = self.tasks_api.put_move_task_to_sibling(put_request)
        self.assertIsNotNone(put_result)
        self.assertIsInstance(put_result, AsposeResponse)

        get_request = GetTaskRequest(filename, 38)
        get_result = self.tasks_api.get_task(get_request)
        self.assertIsNotNone(get_result)
        self.assertIsInstance(get_result, TaskResponse)
        self.assertEqual([39, 40, 41], get_result.task.subtasks_uids)
    def test_post_task(self):
        filename = 'Project2016.mpp'
        self.upload_file(filename)
        post_request = PostTaskRequest(filename, 'New task name', 4)
        post_result = self.tasks_api.post_task(post_request)
        self.assertIsNotNone(post_result)
        self.assertIsInstance(post_result, TaskItemResponse)
        self.assertIsNotNone(post_result.task_item)

        get_request = GetTaskRequest(filename, post_result.task_item.uid)
        get_result = self.tasks_api.get_task(get_request)
        self.assertIsNotNone(get_result)
        self.assertIsInstance(get_result, TaskResponse)
        self.assertIsNotNone(get_result.task)
 def test_get_task(self):
     filename = 'Project2016.mpp'
     self.upload_file(filename)
     get_request = GetTaskRequest(filename, 5)
     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(5, get_result.task.uid)
     self.assertEqual([1, 2, 3, 4], get_result.task.subtasks_uids)
     self.assertEqual('Summary Task 1', get_result.task.name)
     self.assertEqual(datetime(2015, 8, 3, 8, 0, 0), get_result.task.start)
     self.assertEqual(datetime(2015, 8, 6, 17, 0, 0),
                      get_result.task.finish)
     self.assertEqual('1.08:00:00', get_result.task.remaining_work)
     self.assertEqual(1920, get_result.task.work_variance)
    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_move_task(self):
        filename = 'sample.mpp'
        self.upload_file(filename)
        get_request = GetTaskRequest(filename, 6)
        get_result = self.tasks_api.get_task(get_request)
        self.assertIsNotNone(get_result)
        self.assertIsInstance(get_result, TaskResponse)
        self.assertIsNone(
            next((s for s in get_result.task.subtasks_uids if s == 10), None))

        put_request = PutMoveTaskRequest(filename, 10, 6)
        put_result = self.tasks_api.put_move_task(put_request)
        self.assertIsNotNone(put_result)
        self.assertIsInstance(put_result, AsposeResponse)

        get_result = self.tasks_api.get_task(get_request)
        self.assertIsNotNone(get_result)
        self.assertIsInstance(get_result, TaskResponse)
        self.assertIsNotNone(
            next((s for s in get_result.task.subtasks_uids if s == 10), None))
예제 #12
0
    def test_post_assignment(self):
        filename = 'NewProductDev.mpp'
        self.upload_file(filename)
        request = PostAssignmentRequest(filename, 0, 1, 0.5)
        result = self.tasks_api.post_assignment(request)
        self.assertIsNotNone(result)
        self.assertIsInstance(result, AssignmentItemResponse)
        self.assertIsNotNone(result.assignment_item)

        assignment_uid = result.assignment_item.uid
        get_response = self.tasks_api.get_assignment(GetAssignmentRequest(filename, assignment_uid))
        get_task_response = self.tasks_api.get_task(GetTaskRequest(filename, 0))

        self.assertIsInstance(get_response, AssignmentResponse)
        self.assertIsNotNone(get_response.assignment)
        self.assertEqual(get_response.assignment.task_uid, 0)
        self.assertEqual(1, get_response.assignment.resource_uid)
        self.assertIsInstance(get_task_response, TaskResponse)
        self.assertIsNotNone(get_task_response.task)
        self.assertEqual(get_task_response.task.start, get_response.assignment.start)
        self.assertEqual(get_task_response.task.finish, get_response.assignment.finish)
        self.assertEqual(get_task_response.task.work, get_response.assignment.work)
        self.assertEqual(get_task_response.task.cost, get_response.assignment.cost)
    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)