Ejemplo n.º 1
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")