Skip to content

Commit a6295b8

Browse files
author
Luiko Czub
committed
Rename exception TestLinkErrors -> TestLinkError
#1
1 parent 93029a1 commit a6295b8

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/testlink/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
# see https://github.com/orenault/TestLink-API-Python-client/issues/4
88

99

10-
from .testlinkerrors import TestLinkErrors
10+
from .testlinkerrors import TestLinkError
1111
from .testlink import TestLinkAPIClient, TestLink
1212
from .testlinkhelper import TestLinkHelper

src/testlink/testlink.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sys
1414
from datetime import date
1515
from testlinkhelper import TestLinkHelper
16-
from testlinkerrors import TestLinkErrors
16+
from testlinkerrors import TestLinkError
1717

1818
class TestLinkAPIClient(object):
1919

@@ -568,17 +568,17 @@ def getTestCaseIDByName(self, testCaseName, testSuiteName, testProjectName):
568568
Find a test case by its name, by its suite and its project
569569
Suite name must not be duplicate, so only one test case must be found
570570
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
572572
"""
573573
results = super(TestLink, self).getTestCaseIDByName(testCaseName, testSuiteName, testProjectName)
574574
if results[0].has_key("message"):
575-
raise TestLinkErrors(results[0]["message"])
575+
raise TestLinkError(results[0]["message"])
576576
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")
578578
else:
579579
if results[0]["name"] == testCaseName:
580580
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!")
582582

583583

584584
def reportResult(self, testResult, testCaseName, testSuiteName, testNotes="", **kwargs):
@@ -593,28 +593,28 @@ def reportResult(self, testResult, testCaseName, testSuiteName, testNotes="", **
593593
- testProjectName: the project to fill
594594
- testPlanName: the active test plan
595595
- 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
597597
Return the execution id needs to attach files to test execution
598598
"""
599599

600600
# Check parameters
601601
for data in ["testProjectName", "testPlanName", "buildName"]:
602602
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)
604604

605605
# Get project id
606606
project = self.getTestProjectByName(kwargs["testProjectName"])
607607

608608
# Check if project is active
609609
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"])
611611

612612
# Check test plan name
613613
plan = self.getTestPlanByName(kwargs["testProjectName"], kwargs["testPlanName"])
614614

615615
# Check is test plan is open and active
616616
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"])
618618
# Memorise test plan id
619619
planId = plan['id']
620620

@@ -623,14 +623,14 @@ def reportResult(self, testResult, testCaseName, testSuiteName, testNotes="", **
623623

624624
# Check if build is open and active
625625
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"])
627627

628628
# Get test case id
629629
caseId = self.getTestCaseIDByName(testCaseName, testSuiteName, kwargs["testProjectName"])
630630

631631
# Check results parameters
632632
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'")
634634

635635
if testNotes == "":
636636
# Builds testNotes if empty
@@ -645,51 +645,51 @@ def reportResult(self, testResult, testCaseName, testSuiteName, testNotes="", **
645645
results = self.reportTCResult(caseId, planId, kwargs["buildName"], testResult, testNotes)
646646
# Check errors
647647
if results[0]["message"] != "Success!":
648-
raise TestLinkErrors(results[0]["message"])
648+
raise TestLinkError(results[0]["message"])
649649

650650
return results[0]['id']
651651

652652
def getTestProjectByName(self, testProjectName):
653653
"""
654654
Return project
655-
A TestLinkErrors is raised in case of error
655+
A TestLinkError is raised in case of error
656656
"""
657657
results = super(TestLink, self).getTestProjectByName(testProjectName)
658658
if results[0].has_key("message"):
659-
raise TestLinkErrors(results[0]["message"])
659+
raise TestLinkError(results[0]["message"])
660660

661661
return results[0]
662662

663663
def getTestPlanByName(self, testProjectName, testPlanName):
664664
"""
665665
Return test plan
666-
A TestLinkErrors is raised in case of error
666+
A TestLinkError is raised in case of error
667667
"""
668668
results = super(TestLink, self).getTestPlanByName(testProjectName, testPlanName)
669669
if results[0].has_key("message"):
670-
raise TestLinkErrors(results[0]["message"])
670+
raise TestLinkError(results[0]["message"])
671671

672672
return results[0]
673673

674674
def getBuildByName(self, testProjectName, testPlanName, buildName):
675675
"""
676676
Return build corresponding to buildName
677-
A TestLinkErrors is raised in case of error
677+
A TestLinkError is raised in case of error
678678
"""
679679
plan = self.getTestPlanByName(testProjectName, testPlanName)
680680
builds = self.getBuildsForTestPlan(plan['id'])
681681

682682
# Check if a builds exists
683683
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))
685685

686686
# Search the correct build name in the return builds list
687687
for build in builds:
688688
if build['name'] == buildName:
689689
return build
690690

691691
# 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))
693693

694694
if __name__ == "__main__":
695695
tl_helper = TestLinkHelper()

src/testlink/testlinkerrors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Licensed under ???
77
# see https://github.com/orenault/TestLink-API-Python-client/issues/4
88

9-
class TestLinkErrors(Exception):
9+
class TestLinkError(Exception):
1010
""" Basic error handler
1111
Return message pass as argument
1212
"""

test/test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'''
1414

1515
import re
16-
from testlink import TestLink, TestLinkErrors, TestLinkHelper
16+
from testlink import TestLink, TestLinkError, TestLinkHelper
1717
from nose.tools import *
1818

1919
class TestClass():
@@ -34,21 +34,21 @@ def test_getTestCaseIDByName(self):
3434
assert_equal(val, '31' )
3535

3636
# Check if an error is raised in case of bad parameters
37-
assert_raises(TestLinkErrors, self.client.getTestCaseIDByName, "Initialisation", "Séquence 1", "Test 2")
37+
assert_raises(TestLinkError, self.client.getTestCaseIDByName, "Initialisation", "Séquence 1", "Test 2")
3838

3939
def test_getTestProjectByName(self):
4040
project = self.client.getTestProjectByName("Test 2")
4141
assert_equals(type(project), dict)
4242
# Check if an error is raised in case of bad parameters
43-
assert_raises(TestLinkErrors, self.client.getTestProjectByName, "Unknown project")
43+
assert_raises(TestLinkError, self.client.getTestProjectByName, "Unknown project")
4444

4545
def test_getTestPlanByName(self):
4646
plan_ok = self.client.getTestPlanByName("Test 2", "Full")
4747

4848
# Assume that plan id is 33
4949
assert_equal(plan_ok['id'], '33')
5050

51-
assert_raises(TestLinkErrors, self.client.getTestPlanByName, "Test 2", "Name Error")
51+
assert_raises(TestLinkError, self.client.getTestPlanByName, "Test 2", "Name Error")
5252

5353
def test_getBuildByName(self):
5454
pass

0 commit comments

Comments
 (0)