Ejemplo n.º 1
0
    def update_1_case_result_for_run(self, run, testcase, result, user,
                                     comment):

        if not comment:
            comment = ''

        tr = TestRun(run.strip(), None, TestRun.default_project)
        print('Update %s:' % run)

        if user == 'None':
            user = TestRun.logged_in_user_id

        is_found = False
        for rec in tr.records:
            if rec.test_case_id == testcase:
                is_found = True
                rec.executed = datetime.datetime.now()
                rec.executed_by = user
                rec.result = result
                rec.comment = comment

                tr.update_test_record_by_object(testcase, rec)
                print("%4sSet %s to %s (verdict comment: '%s')" %
                      ('', testcase, result, comment))
                return 0

        if not is_found:
            print('Test case %s is not found in run.' % testcase)
Ejemplo n.º 2
0
    def update_all_case_results_for_run(self, run, result, user, comment):

        run = run.strip()
        tr = TestRun(run, None, TestRun.default_project)
        print('\nUpdate %s:' % run)

        if not comment:
            comment = ''

        print('Total records: %d' % len(tr.records))
        print('Updated Date Time    Result  CaseID')
        print('-------------------  ------  -----------')

        if user == 'None':
            user = TestRun.logged_in_user_id

        for rec in tr.records:
            rec.executed = datetime.datetime.now()
            rec.executed_by = user
            executed_str = str(rec.executed).split('.')[0]
            rec.result = result
            rec.comment = comment

            print('%-20s %-7s %s' % (executed_str, result, rec.test_case_id))
            tr.update_test_record_by_object(rec.test_case_id, rec)
        print('Done!')
Ejemplo n.º 3
0
    def update_1_result_for_run(self,
                                run,
                                testcase,
                                result,
                                user,
                                comment):

        if not comment:
            comment = ''

        tr = TestRun(run.strip(), None, TestRun.default_project)
        print 'Update %s:' % run

        if user == 'None':
            user = TestRun.logged_in_user_id

        for rec in tr.records:
            rec.executed = datetime.datetime.now()
            rec.executed_by = user
            rec.result = result
            rec.comment = comment

            if rec.test_case_id == testcase:
                tr.update_test_record_by_object(testcase, rec)
                print '%4sSet %s to %s (verdict %s)' % ('',
                                                        testcase,
                                                        result,
                                                        comment)
        print 'Done!'
Ejemplo n.º 4
0
    def update_all_results_for_run(self, run, result, user, comment):

        tr = TestRun(run.strip(), None, TestRun.default_project)
        print 'Update %s:' % run.strip()

        if not comment:
            comment = ''

        print 'Total records: %d' % len(tr.records)
        print 'Updated Date Time    Result  CaseID'
        print '-------------------  ------  -----------'

        if user == 'None':
            user = TestRun.logged_in_user_id

        for rec in tr.records:
            rec.executed = datetime.datetime.now()
            rec.executed_by = user
            executed_str = str(rec.executed).split('.')[0]
            rec.result = result
            rec.comment = comment

            print '%-20s %-7s %s' % (executed_str,
                                     result,
                                     rec.test_case_id)
            tr.update_test_record_by_object(rec.test_case_id,
                                            rec)
        print 'Done!'
Ejemplo n.º 5
0
 def test_013_incident_report_test(self):
     """This test does the following:
     * gets a TestRun
     * gets a TestCase
     * adds test_steps
     * creates a TestRecord
     * populates the TestRecord
     * Fail the testRecord
     * reloads the TestCase
     * Verifies that an Incident Report was Created
     """
     tr = TestRun(project_id=DEFAULT_PROJ, test_run_id=TEST_RUN_ID)
     tests = [["Test 1", "Result 1"], ["Test 2", "Result 2"],
              ["Test 3", "Result 3"]]
     set_steps = []
     for test in tests:
         ts = TestStep()
         ts.values = test
         set_steps.append(ts)
     tc = TestCase(work_item_id=self.NEW_TEST_CASE)
     tc.set_test_steps(set_steps)
     tc.update()
     tc.reload()
     steps = tc.test_steps.steps
     results = []
     for step in steps:
         res = TestStepResult()
         res.result = "failed"
         res.comment = "This is the result"
         results.append(res)
     rec = TestRecord()
     rec.test_step_results = results
     rec.test_case_id = self.NEW_TEST_CASE
     rec.comment = "Incident Report was Created"
     rec.duration = "50.5"
     rec.result = "failed"
     rec.executed_by = tr.logged_in_user_id
     rec.executed = datetime.datetime.now()
     tr.update_test_record_by_object(self.NEW_TEST_CASE, rec)
     tc.reload()
     linked_work_items = tc.linked_work_items_derived
     idx = len(linked_work_items) - 1
     incident = Incident(project_id="proj1",
                         work_item_id=linked_work_items[idx].work_item_id)
     self.assertIsNotNone(incident)
Ejemplo n.º 6
0
    def test_006_test_record_by_object(self):
        """This test does the following:
        * gets a TestRun
        * creates a TestRecord
        * populates the TestRecord
        * Tries to add a duplicate TestRecord (should fail)
        * Adds a TestRecord
        * Reloads the TestRun
        * Verifies the TestRecord was added
        * Updates the TestRecord
        * Reloads the TestRun
        * Verifies the TestRecord was modified
        """
        tr = TestRun(project_id=DEFAULT_PROJ, test_run_id=TEST_RUN_ID)
        rec = TestRecord()
        rec.test_case_id = self.NEW_TEST_CASE
        rec.comment = "No Comment"
        rec.duration = "50.5"
        # verify that it does not allow duplicate records.
        # (same record was added in previous test)
        with self.assertRaises(PylarionLibException):
            tr.add_test_record_by_object(rec)
        rec.test_case_id = self.NEW_TEST_CASE2
        tr.add_test_record_by_object(rec)
        tr.reload()
        check_rec = tr.records[-1]
        self.assertEqual(tr.status, "inprogress")
        self.assertEqual(check_rec.test_case_id, self.NEW_TEST_CASE2)
        rec.result = "blocked"
        rec.executed_by = tr.logged_in_user_id
        rec.executed = datetime.datetime.now()
        tr.update_test_record_by_object(self.NEW_TEST_CASE2, rec)
        tr.reload()
        self.assertEqual(tr.status, "finished")

        check_rec = tr.records[-1]
        self.assertEqual(check_rec.result, "blocked")