Ejemplo n.º 1
0
    def update_run(self,
                   run,
                   template=None,
                   plannedin=None,
                   assignee=None,
                   status=None,
                   description=None,
                   is_template=False):

        run = run.strip()
        query_ful = 'project.id:%s AND id:%s' % (TestRun.default_project, run)

        fields = [
            'query', 'created', 'test_run_id', 'select_test_cases_by',
            'status', 'plannedin', 'assignee', 'author'
        ]
        st = TestRun.search(query_ful, fields, 'created', -1, is_template)

        # Update run if exists, otherwise create it.
        if st:
            print('Update the existing run: %s' % run)
            tr = TestRun(run, None, TestRun.default_project)

            # set fields
            if assignee != 'None':
                tr.assignee = assignee
                print('%4sSet Assignee to %s' % ('', assignee))
            if plannedin is not None:
                tr.plannedin = plannedin
                print('%4sSet Plannedin to %s' % ('', plannedin))
            if status is not None:
                tr.status = status
                print('%4sSet Status to %s' % ('', status))
            if description is not None:
                tr.description = description
                print('%4sSet Description to %s' % ('', description))
            tr.update()

        else:
            tr = TestRun.create(TestRun.default_project,
                                run,
                                template,
                                assignee=assignee,
                                plannedin=plannedin,
                                status=status,
                                description=description)
            # display fields
            if assignee != 'None':
                print('%4sSet Assignee to %s' % ('', assignee))
            if plannedin is not None:
                print('%4sSet Plannedin to %s' % ('', plannedin))
            if status is not None:
                print('%4sSet Status to %s' % ('', status))
            if description is not None:
                print('%4sSet Description to %s' % ('', description))
            print('Created %s:' % run)