예제 #1
0
    def test_create(self):
        task = Task.create('test task')

        self.assertIsNotNone(task)
        self.assertRegex(task.uuid, r'%s' % UUID4_REGEX)
        self.assertEqual('test task', task.description)
        self.assertEqual(0, task.done)
예제 #2
0
    def create_task(self, name: str, description: str, date_start: str,
                    duration: int):
        """
        Create new Task

        :param name: name of new Task
        :param description: description of new Task
        :param date_start: start date of new Task
        :param duration: duration of new Task
        :return: created Task entity
        >>> a = DataManager.load_from_file(test_suits_folder_path + "/test_suit5.json")
        >>> task = Task(1, "quest", "desc", parser.parse("2018"), parser.parse("2018-06-03T00:00:34"), False)
        >>> b = a.create_task("quest", "desc", "2018", 34)
        >>> task.task_id = a.next_id - 1
        >>> b == task
        True
        """
        self.update_from_file(self.storage_path)
        task = Task.create(self.next_id, name, description, date_start,
                           duration)
        self.tasks.append(task)
        self.next_id += 1
        self.save_to_file(self.storage_path)
        return task
예제 #3
0
class TaskController:
    def __init__(self, id, uuid):
        self.task = Task()
        # self.helper = TestCaseHelper()
        # self.env = Environment()
        # self.sql_server = self.env.pvedb.db_server
        # self.sql_user = self.env.pvedb.db_user
        # self.sql_pwd = self.env.pvedb.db_pwd
        # self.sql_db = self.env.pvedb.db_name
        # self.crud = Crud(dbo.PVEDB(self.sql_server, self.sql_user, self.sql_pwd, self.sql_db))
        # self.id = id
        # self.uuid = uuid
        # self.list_create_task_values, self.list_dict_node_values = [], []

    def create(self, father_key, name='Task', encoding='utf-8'):
        logger.logs('\n Creating PVE task \n', 'info')
        description = self.helper.get_name(name)
        self.list_create_task_values = [{
            'ns1:Description': description,
            'ns1:FatherKey': father_key
        }]

        self.task.create(self.list_create_task_values, encoding)
        task_key = self.task.verify_created_key

        status = self.verify_create(encoding)
        return description, task_key, status

    def update(self,
               task_key,
               father_key,
               milestone='false',
               encoding='utf-8',
               **kwargs):
        logger.logs('\n Updating PVE task \n', 'info')
        update_desc = self.helper.get_name('Updated_Task')
        if milestone == 'true' and 'schedule_start' in kwargs:
            self.list_dict_node_values = [{
                r'ns1:Description':
                update_desc,
                r'ns1:Key':
                task_key,
                r'ns1:FatherKey':
                father_key,
                r'ns1:IsMilestone':
                milestone,
                r'ns1:ScheduleStartDate':
                kwargs['schedule_start'],
                r'ns1:EnterProgress':
                kwargs['enter_progress'],
                r'ns1:Duration':
                0
            }]
            operation = 'update'

        else:
            if 'Actual_Finish' in kwargs and 'Actual_Start' in kwargs:
                self.list_dict_node_values = [{
                    r'ns1:Description':
                    update_desc,
                    r'ns1:Key':
                    task_key,
                    r'ns1:FatherKey':
                    father_key,
                    r'ns1:IsMilestone':
                    milestone,
                    r'ns1:EnterProgress':
                    kwargs['enter_progress'],
                    r'ns1:ActualFinishDate':
                    kwargs['Actual_Finish'],
                    r'ns1:ActualStartDate':
                    kwargs['Actual_Start']
                }]
                operation = 'update_actual'

            elif 'Actual_Start' in kwargs and 'Schedule_start' in kwargs:
                self.list_dict_node_values = [{
                    r'ns1:Description':
                    update_desc,
                    r'ns1:Key':
                    task_key,
                    r'ns1:FatherKey':
                    father_key,
                    r'ns1:EnterProgress':
                    kwargs['enter_progress'],
                    r'ns1:ActualStartDate':
                    kwargs['Actual_Start'],
                    r'ns1:ScheduleStartDate':
                    kwargs['Schedule_start'],
                    r'ns1:ScheduleFinishDate':
                    kwargs['Schedule_Finish']
                }]

                operation = 'update_start_date'

            else:
                self.list_dict_node_values = [{
                    r'ns1:Description':
                    update_desc,
                    r'ns1:Key':
                    task_key,
                    r'ns1:FatherKey':
                    father_key,
                    r'ns1:EnterProgress':
                    kwargs['enter_progress'],
                    r'ns1:ScheduleFinishDate':
                    kwargs['Schedule_Finish'],
                    r'ns1:ScheduleStartDate':
                    kwargs['Schedule_start']
                }]
                operation = 'update_schedule'

        self.task.update(self.list_dict_node_values, operation, encoding)

        status = self.verify_update(encoding)
        return update_desc, status

    def read(self, planning_code):
        return pve_qhandler.select_schedule_actual_dates(
            planning_code, self.crud)

    def verify_create(self, encoding='utf-8'):
        logger.logs('\n Verifying the created task \n', 'info')
        result, remarks = self.task.verify_create(encoding)

        step_desc = 'Creation and Verification of the Task'
        step_input = 'Task: %s' % self.list_create_task_values

        last_run = self.helper.get_time()
        create_status = False
        step_result = 0

        if result:
            step_result = 1
            create_status = True
        qhandler.insert_into_step_details(
            self.id, self.uuid, self.env.pve.name, self.env.pve.db_name,
            self.env.external_env.name, self.env.integ.name, step_desc,
            step_input, step_result, remarks, last_run)
        logger.logs('Task create verification: %s' % create_status, 'info')
        return create_status

    def verify_update(self, encoding='utf-8'):
        logger.logs('\n Verifying the updated task \n', 'info')
        result, remarks = self.task.verify_update(encoding)

        step_desc = 'Update and Verification of the Task'
        step_input = 'Task: %s' % self.list_dict_node_values
        last_run = self.helper.get_time()
        update_status = False
        step_result = 0

        if result:
            step_result = 1
            update_status = True
        qhandler.insert_into_step_details(
            self.id, self.uuid, self.env.pve.name, self.env.pve.db_name,
            self.env.external_env.name, self.env.integ.name, step_desc,
            step_input, step_result, remarks, last_run)
        logger.logs('Task update verification: %s' % update_status, 'info')
        return update_status
예제 #4
0
파일: j.py 프로젝트: tonghuashuai/OnlyBoard
    def post(self):
        type_ = self.get_argument('type')
        title = self.get_argument('title')
        Task.create(type=type_, title=title)

        self.finish()