@@ -177,9 +177,6 @@ def getTestCaseIDByName(self, testCaseName, testSuiteName=None, testProjectName=
177
177
else :
178
178
return ret_srv
179
179
180
-
181
-
182
-
183
180
def getTestCasesForTestPlan (self , * args ):
184
181
""" getTestCasesForTestPlan :
185
182
List test cases linked to a test plan
@@ -362,7 +359,7 @@ def createTestCase(self, *args):
362
359
self .stepsList = []
363
360
return ret
364
361
365
- def __reportTCResult (self , testcaseid , testplanid , buildname , status , notes ):
362
+ def reportTCResult (self , testcaseid , testplanid , buildname , status , notes ):
366
363
"""
367
364
Report execution result
368
365
testcaseid: internal testlink id of the test case
@@ -382,24 +379,6 @@ def __reportTCResult(self, testcaseid, testplanid, buildname, status, notes ):
382
379
}
383
380
return self .server .tl .reportTCResult (argsAPI )
384
381
385
- def reportResult (self , testCaseName , testSuiteName , testProjectName ):
386
- pass
387
-
388
- def setReportCtx (self , testProjectName , testPlanName , buildName ):
389
- """
390
- Set project name test plan name and build name for reportResult function
391
- """
392
- project = getTestProjectByName (testProjectName )
393
- if project [0 ].has_key ("message" ):
394
- sys .exit (project [0 ]["message" ])
395
-
396
- # Check if project is active
397
- if project [0 ]['active' ] != '1' :
398
- sys .exit ("(getTestProjectByName) - Test project (name:%s) is not active" % testProjectName )
399
-
400
- # Store project id
401
- self .projectId = project [0 ]['id' ]
402
- #TODO: à finir
403
382
404
383
405
384
def uploadExecutionAttachment (self ,attachmentfile ,executionid ,title ,description ):
@@ -589,8 +568,7 @@ def __init__(self, server_url, key):
589
568
"""
590
569
Class initialisation
591
570
"""
592
-
593
- super (testlink , self ).__init__ (server_url , key )
571
+ super (TestLink , self ).__init__ (server_url , key )
594
572
595
573
def getTestCaseIDByName (self , testCaseName , testSuiteName , testProjectName ):
596
574
"""
@@ -599,7 +577,7 @@ def getTestCaseIDByName(self, testCaseName, testSuiteName, testProjectName):
599
577
Return test case id if success
600
578
or raise TestLinkErrors exception with error message in case of error
601
579
"""
602
- results = super (testlink , self ).getTestCaseIDByName (testCaseName , testSuiteName , testProjectName )
580
+ results = super (TestLink , self ).getTestCaseIDByName (testCaseName , testSuiteName , testProjectName )
603
581
if results [0 ].has_key ("message" ):
604
582
raise TestLinkErrors (results [0 ]["message" ])
605
583
elif len (results ) > 1 :
@@ -610,3 +588,68 @@ def getTestCaseIDByName(self, testCaseName, testSuiteName, testProjectName):
610
588
raise TestLinkErrors ("(getTestCaseIDByName) - Internal server error. Return value is not expected one!" )
611
589
612
590
591
+ def reportResult (self , testResult , testCaseName , testSuiteName , testNotes , ** kwargs ):
592
+ """
593
+ Report results for test case
594
+ Arguments are:
595
+ - testResult: "p" for passed, "b" for blocked, "f" for failed
596
+ - testCaseName: the test case name to report
597
+ - testSuiteName: the test suite name that support the test case
598
+ - an anonymous dictionnary with followings keys:
599
+ - testProjectName: the project to fill
600
+ - testPlanName: the active test plan
601
+ - buildName: the active build.
602
+ Raise a TestLinkErrors error with the error message in case of trouble
603
+ """
604
+
605
+ # Check parameters
606
+ for data in ["testProjectName" , "testPlanName" , "buildName" ]:
607
+ if not kwargs .has_key (data ):
608
+ raise TestLinkErrors ("(reportResult) - Missing key %s in anonymous dictionnary" % data )
609
+
610
+ # Get project id
611
+ project = self .getTestProjectByName (kwargs ["testProjectName" ])
612
+
613
+ # Check if project is active
614
+ if project ['active' ] != '1' :
615
+ raise TestLinkErrors ("(reportResult) - Test project %s is not active" % kwargs ["testProjectName" ])
616
+ # Memorize project id
617
+ projectId = project ['id' ]
618
+
619
+ # Check test plan name
620
+ plan = self .getTestPlanByName (kwargs ["testProjectName" ], kwargs ["testPlanName" ])
621
+
622
+ # Check is test plan is open and active
623
+ if results [0 ]['is_open' ] != '1' or results [0 ]['active' ] != '1' :
624
+ raise TestLinkErrors ("(reportResult) - Test plan %s is not active or not open" % kwargs ["testPlanName" ])
625
+
626
+
627
+ # Check results parameters
628
+ if testResults not in "pbf" :
629
+ raise TestLinkErrors ("(reportResult) - Test result must be 'p', 'f' or 'b'" )
630
+
631
+
632
+ results = self .reportTCResult (testCaseName , testSuiteName , testProjectName )
633
+ #TODO: à terminer
634
+
635
+ def getTestProjectByName (self , testProjectName ):
636
+ """
637
+ Return project
638
+ A TestLinkError is raised in case of error
639
+ """
640
+ results = super (TestLink , self ).getTestProjectByName (testProjectName )
641
+ if results [0 ].has_key ("message" ):
642
+ raise TestLinkErrors (results [0 ]["message" ])
643
+
644
+ return results [0 ]
645
+
646
+ def getTestPlanByName (self , testProjectName , testPlanName ):
647
+ """
648
+ Return test plan
649
+ A TestLinkErrors is raised in case of error
650
+ """
651
+ results = super (TestLink , self ).getTestPlanByName (testProjectName , testPlanName )
652
+ if results [0 ].has_key ("message" ):
653
+ raise TestLinkErrors (results [0 ]. ["message" ])
654
+
655
+ return results [0 ]
0 commit comments