13
13
import sys
14
14
from datetime import date
15
15
from testlinkhelper import TestLinkHelper
16
- from testlinkerrors import TestLinkErrors
16
+ from testlinkerrors import TestLinkError
17
17
18
18
class TestLinkAPIClient (object ):
19
19
@@ -568,17 +568,17 @@ def getTestCaseIDByName(self, testCaseName, testSuiteName, testProjectName):
568
568
Find a test case by its name, by its suite and its project
569
569
Suite name must not be duplicate, so only one test case must be found
570
570
Return test case id if success
571
- or raise TestLinkErrors exception with error message in case of error
571
+ or raise TestLinkError exception with error message in case of error
572
572
"""
573
573
results = super (TestLink , self ).getTestCaseIDByName (testCaseName , testSuiteName , testProjectName )
574
574
if results [0 ].has_key ("message" ):
575
- raise TestLinkErrors (results [0 ]["message" ])
575
+ raise TestLinkError (results [0 ]["message" ])
576
576
elif len (results ) > 1 :
577
- raise TestLinkErrors ("(getTestCaseIDByName) - Several case test found. Suite name must not be duplicate for the same project" )
577
+ raise TestLinkError ("(getTestCaseIDByName) - Several case test found. Suite name must not be duplicate for the same project" )
578
578
else :
579
579
if results [0 ]["name" ] == testCaseName :
580
580
return results [0 ]["id" ]
581
- raise TestLinkErrors ("(getTestCaseIDByName) - Internal server error. Return value is not expected one!" )
581
+ raise TestLinkError ("(getTestCaseIDByName) - Internal server error. Return value is not expected one!" )
582
582
583
583
584
584
def reportResult (self , testResult , testCaseName , testSuiteName , testNotes = "" , ** kwargs ):
@@ -593,28 +593,28 @@ def reportResult(self, testResult, testCaseName, testSuiteName, testNotes="", **
593
593
- testProjectName: the project to fill
594
594
- testPlanName: the active test plan
595
595
- buildName: the active build.
596
- Raise a TestLinkErrors error with the error message in case of trouble
596
+ Raise a TestLinkError error with the error message in case of trouble
597
597
Return the execution id needs to attach files to test execution
598
598
"""
599
599
600
600
# Check parameters
601
601
for data in ["testProjectName" , "testPlanName" , "buildName" ]:
602
602
if not kwargs .has_key (data ):
603
- raise TestLinkErrors ("(reportResult) - Missing key %s in anonymous dictionnary" % data )
603
+ raise TestLinkError ("(reportResult) - Missing key %s in anonymous dictionnary" % data )
604
604
605
605
# Get project id
606
606
project = self .getTestProjectByName (kwargs ["testProjectName" ])
607
607
608
608
# Check if project is active
609
609
if project ['active' ] != '1' :
610
- raise TestLinkErrors ("(reportResult) - Test project %s is not active" % kwargs ["testProjectName" ])
610
+ raise TestLinkError ("(reportResult) - Test project %s is not active" % kwargs ["testProjectName" ])
611
611
612
612
# Check test plan name
613
613
plan = self .getTestPlanByName (kwargs ["testProjectName" ], kwargs ["testPlanName" ])
614
614
615
615
# Check is test plan is open and active
616
616
if plan ['is_open' ] != '1' or plan ['active' ] != '1' :
617
- raise TestLinkErrors ("(reportResult) - Test plan %s is not active or not open" % kwargs ["testPlanName" ])
617
+ raise TestLinkError ("(reportResult) - Test plan %s is not active or not open" % kwargs ["testPlanName" ])
618
618
# Memorise test plan id
619
619
planId = plan ['id' ]
620
620
@@ -623,14 +623,14 @@ def reportResult(self, testResult, testCaseName, testSuiteName, testNotes="", **
623
623
624
624
# Check if build is open and active
625
625
if build ['is_open' ] != '1' or build ['active' ] != '1' :
626
- raise TestLinkErrors ("(reportResult) - Build %s in not active or not open" % kwargs ["buildName" ])
626
+ raise TestLinkError ("(reportResult) - Build %s in not active or not open" % kwargs ["buildName" ])
627
627
628
628
# Get test case id
629
629
caseId = self .getTestCaseIDByName (testCaseName , testSuiteName , kwargs ["testProjectName" ])
630
630
631
631
# Check results parameters
632
632
if testResult not in "pbf" :
633
- raise TestLinkErrors ("(reportResult) - Test result must be 'p', 'f' or 'b'" )
633
+ raise TestLinkError ("(reportResult) - Test result must be 'p', 'f' or 'b'" )
634
634
635
635
if testNotes == "" :
636
636
# Builds testNotes if empty
@@ -645,51 +645,51 @@ def reportResult(self, testResult, testCaseName, testSuiteName, testNotes="", **
645
645
results = self .reportTCResult (caseId , planId , kwargs ["buildName" ], testResult , testNotes )
646
646
# Check errors
647
647
if results [0 ]["message" ] != "Success!" :
648
- raise TestLinkErrors (results [0 ]["message" ])
648
+ raise TestLinkError (results [0 ]["message" ])
649
649
650
650
return results [0 ]['id' ]
651
651
652
652
def getTestProjectByName (self , testProjectName ):
653
653
"""
654
654
Return project
655
- A TestLinkErrors is raised in case of error
655
+ A TestLinkError is raised in case of error
656
656
"""
657
657
results = super (TestLink , self ).getTestProjectByName (testProjectName )
658
658
if results [0 ].has_key ("message" ):
659
- raise TestLinkErrors (results [0 ]["message" ])
659
+ raise TestLinkError (results [0 ]["message" ])
660
660
661
661
return results [0 ]
662
662
663
663
def getTestPlanByName (self , testProjectName , testPlanName ):
664
664
"""
665
665
Return test plan
666
- A TestLinkErrors is raised in case of error
666
+ A TestLinkError is raised in case of error
667
667
"""
668
668
results = super (TestLink , self ).getTestPlanByName (testProjectName , testPlanName )
669
669
if results [0 ].has_key ("message" ):
670
- raise TestLinkErrors (results [0 ]["message" ])
670
+ raise TestLinkError (results [0 ]["message" ])
671
671
672
672
return results [0 ]
673
673
674
674
def getBuildByName (self , testProjectName , testPlanName , buildName ):
675
675
"""
676
676
Return build corresponding to buildName
677
- A TestLinkErrors is raised in case of error
677
+ A TestLinkError is raised in case of error
678
678
"""
679
679
plan = self .getTestPlanByName (testProjectName , testPlanName )
680
680
builds = self .getBuildsForTestPlan (plan ['id' ])
681
681
682
682
# Check if a builds exists
683
683
if builds == '' :
684
- raise TestLinkErrors ("(getBuildByName) - Builds %s does not exists for test plan %s" % (buildName , testPlanName ))
684
+ raise TestLinkError ("(getBuildByName) - Builds %s does not exists for test plan %s" % (buildName , testPlanName ))
685
685
686
686
# Search the correct build name in the return builds list
687
687
for build in builds :
688
688
if build ['name' ] == buildName :
689
689
return build
690
690
691
691
# No build found with builName name
692
- raise TestLinkErrors ("(getBuildByName) - Builds %s does not exists for test plan %s" % (buildName , testPlanName ))
692
+ raise TestLinkError ("(getBuildByName) - Builds %s does not exists for test plan %s" % (buildName , testPlanName ))
693
693
694
694
if __name__ == "__main__" :
695
695
tl_helper = TestLinkHelper ()
0 commit comments