Skip to content

Commit

Permalink
Merge "added test run title"
Browse files Browse the repository at this point in the history
  • Loading branch information
szacks authored and Gerrit Code Review committed Sep 22, 2016
2 parents 73dbe17 + 7a65f34 commit c96929d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
42 changes: 30 additions & 12 deletions src/pylarion/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ def generate_description(test_run, test_case, test_record):
"t-bottom;border:0px;margin-right:2px;\" c"
"lass=\"polarion-no-style-cleanup\"/>"
"</span></span>"}
table_header = "<table class=\"polarion-no-style-cleanup\" style=\"border" \
table_header = "<table class=\"polarion-no-style-cleanup\" style=\"border"\
"-collapse: collapse;\"><tr style=\"text-align: left; " \
"white-space: nowrap; color: #757575; border-bottom: 1px " \
"solid #d2d7da; background-color: #ffffff;\">{0}</tr>" \
.format("".join(["<th {0}>{1}</th>".format(table_cell_style, column)
for column in columns]))
verdict = "</table><table style=\"margin-bottom: 15px; ;border-collapse: " \
"collapse; width:100%; ;margin-top: 13px;\" class=\"polarion-no" \
"-style-cleanup\"><tr><th style=\"width: 80%; text-align: left;" \
" background-color: #ffffff;\">Test Case Verdict:</th></tr><tr>" \
"<td style=\"vertical-align: top;\"><span style=\"font-weight: " \
"bold;\"><span style=\"color: #C30000;\"><span title=\"Results " \
verdict = "</table><table style=\"margin-bottom: 15px; ;border-collapse: "\
"collapse; width:100%; ;margin-top: 13px;\" class=\"polarion-no"\
"-style-cleanup\"><tr><th style=\"width: 80%; text-align: left;"\
" background-color: #ffffff;\">Test Case Verdict:</th></tr><tr>"\
"<td style=\"vertical-align: top;\"><span style=\"font-weight: "\
"bold;\"><span style=\"color: #C30000;\"><span title=\"Results "\
"did not meet expected results\"><span style=\"white-space:" \
"nowrap;\"><img src=\"/polarion/icons/default/enums/testrun_" \
"status_failed.png\" style=\"vertical-align:text-bottom;border:" \
"status_failed.png\" style=\"vertical-align:text-bottom;border:"\
"0px;margin-right:2px;\" class=\"polarion-no-style-cleanup\"/>" \
"</span>Failed</span></span></span><span> {0}</span></td></tr>" \
"</table>" \
Expand Down Expand Up @@ -210,6 +210,7 @@ class TestRun(BasePolarion):
"cls": _WorkItem,
"named_arg": "uri",
"sync_field": "uri"},
"title": "title",
"template":
{"field_name": "templateURI",
"named_arg": "uri",
Expand Down Expand Up @@ -277,14 +278,26 @@ def records(self, val):

@classmethod
@tx_wrapper
def create(cls, project_id, test_run_id, template, **kwargs):
def create(cls, project_id, test_run_id=None, template=None, title=None,
**kwargs):
"""class method create for creating a new test run in Polarion
Args:
project_id (string): the Polarion project to create the test run
in
test_run_id (string): the unique identifier for the test run
test_run_id (string): the unique identifier for the test run,
If the Enable Generated Test Run IDs option
is marked in the configuration, it will
ignore this field. If it is None, the title
will be used.
template (string): the id of the template to base the test run on.
cannot be None. Because of the existing order of
params before adding title, it is given a
default value of None, which will cause an error
if it is not populated
title (string): To create a test run with a title. In this case,
if the id is not populated it will be autogen.
If it is populated, it will use that.
**kwargs: keyword arguments. Test run attributes can be passed in
to be set upon creation. Required fields must be passed
in
Expand All @@ -297,8 +310,13 @@ def create(cls, project_id, test_run_id, template, **kwargs):
"""
if not template:
raise PylarionLibException("Template is required")
uri = cls.session.test_management_client.service.createTestRun(
project_id, test_run_id, template)
if title:
uri = cls.session.test_management_client.service.\
createTestRunWithTitle(
project_id, test_run_id or title, title, template)
else:
uri = cls.session.test_management_client.service.createTestRun(
project_id, test_run_id, template)
if uri:
run = cls(uri=uri)
run.verify_params(**kwargs)
Expand Down
22 changes: 21 additions & 1 deletion src/unit_tests/test_run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
CUR_PATH = os.path.dirname(os.path.abspath(__file__))
ATTACH_PATH = CUR_PATH + "/refs/red_box.png"
ATTACH_TITLE = "File"
TITLE1 = "title1_regr-%s" % TIME_STAMP
TITLE2 = "title2_regr-%s" % TIME_STAMP
TEST_RUN_ID2 = "tr2_regr-%s" % TIME_STAMP


class TestRunTest(unittest2.TestCase):
Expand Down Expand Up @@ -77,13 +80,30 @@ def test_001_create_template(self):

def test_002_create_run(self):
"""This test does the following:
* creates a test riun based on the template created in previous test
* creates a test run based on the template created in previous test
* Verifies that the returned object exists and is not a template
"""
tr = TestRun.create(DEFAULT_PROJ, TEST_RUN_ID, TEMPLATE_ID)
self.assertIsNotNone(tr.test_run_id)
self.assertFalse(tr.is_template)

def test_002_5_create_run_with_title(self):
"""This test does the following:
* creates a test run based on the template created in previous test
* with both a title and an id
* with just a title.
* Verifies that the returned object exists and is not a template
"""
tr1 = TestRun.create(DEFAULT_PROJ, TEST_RUN_ID2, TEMPLATE_ID, TITLE1)
self.assertIsNotNone(tr1.test_run_id)
self.assertEqual(tr1.test_run_id, TEST_RUN_ID2)
self.assertEqual(tr1.title, TITLE1)
self.assertFalse(tr1.is_template)
tr2 = TestRun.create(DEFAULT_PROJ, None, TEMPLATE_ID, TITLE2)
self.assertIsNotNone(tr2.test_run_id)
self.assertEqual(tr2.title, TITLE2)
self.assertFalse(tr2.is_template)

def test_003_get(self):
"""This test does the following:
* Verifies error with invalid test_run_id
Expand Down

0 comments on commit c96929d

Please sign in to comment.