Ejemplo n.º 1
0
 def test_005_test_record_by_fields(self):
     """This test does the following:
     * gets a TestRun object
     * Adds a TestRecord to it
     ** verifies that it fails with an invalid result
     ** verifies that it fails if it adds a duplicate case.
     * Adds an attachment to the record.
     ** verifies that the attachment is there
     * deletes the attachment
     ** verifies the attachment is not there
     * updates the test record.
     """
     tr = TestRun(project_id=DEFAULT_PROJ, test_run_id=TEST_RUN_ID)
     with self.assertRaises(PylarionLibException):
         tr.add_test_record_by_fields(self.NEW_TEST_CASE, "invalid",
                                      "No Comment", tr.logged_in_user_id,
                                      datetime.datetime.now(), "50.5")
     tr.add_test_record_by_fields(self.NEW_TEST_CASE, "passed",
                                  "No Comment", tr.logged_in_user_id,
                                  datetime.datetime.now(), "50.5")
     tr.reload()
     self.assertEqual(tr.status, "finished")
     # test that the same case cannot be added multiple times.
     with self.assertRaises(PylarionLibException):
         tr.add_test_record_by_fields(self.NEW_TEST_CASE, "passed",
                                      "No Comment", tr.logged_in_user_id,
                                      datetime.datetime.now(), "50.5")
     tr.reload()
     rec = tr.records[-1]
     tr.add_attachment_to_test_record(rec.test_case_id, ATTACH_PATH,
                                      ATTACH_TITLE)
     tr.reload()
     rec = tr.records[-1]
     self.assertTrue(len(rec.attachments) == 1)
     self.assertEqual(rec.attachments[0].title, ATTACH_TITLE)
     tr.delete_attachment_from_test_record(rec.test_case_id,
                                           rec.attachments[0].filename)
     tr.reload()
     rec = tr.records[-1]
     self.assertEqual(rec.attachments, [])
     tr.update_test_record_by_fields(rec.test_case_id, rec.result,
                                     "Yes Comment", rec.executed_by,
                                     rec.executed, rec.duration)
     tr.reload()
     rec = tr.records[-1]
     self.assertEqual(rec.comment, "Yes Comment")