Skip to content

Commit a1da1a9

Browse files
committed
Fixed for online tests - working with testlink 1.9.12
1 parent c9b1b8d commit a1da1a9

File tree

3 files changed

+44
-31
lines changed

3 files changed

+44
-31
lines changed

test/utest-online/testlinkapi_online_test.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@
2727
# ok to check every implemented server call one time but not
2828
# to cover all possible responses or argument combinations
2929

30-
import unittest, os.path
30+
import sys
31+
import unittest
32+
import os.path
33+
3134
from testlink import TestlinkAPIClient, TestLinkHelper
3235
from testlink.testlinkerrors import TLResponseError
3336

34-
import sys
37+
binary_read_mode = 'rb'
3538
if sys.version_info[0] < 3:
39+
binary_read_mode = 'r'
40+
if sys.version_info[1] < 7:
41+
import unittest2 as unittest
3642
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
3743

3844

39-
4045
class TestLinkAPIOnlineTestCase(unittest.TestCase):
4146
""" TestCases for TestlinkAPIClient - interacts with a TestLink Server.
4247
works with the example project NEW_PROJECT_API (see TestLinkExample.py)
@@ -49,7 +54,6 @@ def setUp(self):
4954
# def tearDown(self):
5055
# pass
5156

52-
5357
def test_checkDevKey(self):
5458
response = self.client.checkDevKey()
5559
self.assertEqual(True, response)
@@ -186,7 +190,7 @@ def test_reportTCResult_unknownID(self):
186190
'note 4714')
187191

188192
def test_uploadExecutionAttachment_unknownID(self):
189-
attachemantFile = open(os.path.realpath(__file__), 'r')
193+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
190194
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
191195
self.client.uploadExecutionAttachment(attachemantFile, 4712,
192196
'title 4713', 'descr. 4714')
@@ -222,37 +226,37 @@ def test_deleteTestCaseSteps_unknownID(self):
222226
self.client.deleteTestCaseSteps('N-4711', steps, version=1)
223227

224228
def test_uploadRequirementSpecificationAttachment_unknownID(self):
225-
attachemantFile = open(os.path.realpath(__file__), 'r')
229+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
226230
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
227231
self.client.uploadRequirementSpecificationAttachment(attachemantFile, 4712,
228232
title='title 4713', description='descr. 4714')
229233

230234
def test_uploadRequirementAttachment_unknownID(self):
231-
attachemantFile = open(os.path.realpath(__file__), 'r')
235+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
232236
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
233237
self.client.uploadRequirementAttachment(attachemantFile, 4712,
234238
title='title 4713', description='descr. 4714')
235239

236240
def test_uploadTestProjectAttachment_unknownID(self):
237-
attachemantFile = open(os.path.realpath(__file__), 'r')
241+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
238242
with self.assertRaisesRegex(TLResponseError, '7000.*4712'):
239243
self.client.uploadTestProjectAttachment(attachemantFile, 4712,
240244
title='title 4713', description='descr. 4714')
241245

242246
def test_uploadTestSuiteAttachment_unknownID(self):
243-
attachemantFile = open(os.path.realpath(__file__), 'r')
247+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
244248
with self.assertRaisesRegex(TLResponseError, '8000.*4712'):
245249
self.client.uploadTestSuiteAttachment(attachemantFile, 4712,
246250
title='title 4713', description='descr. 4714')
247251

248252
def test_uploadTestCaseAttachment_unknownID(self):
249-
attachemantFile = open(os.path.realpath(__file__), 'r')
253+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
250254
with self.assertRaisesRegex(TLResponseError, '5000.*testcaseid'):
251255
self.client.uploadTestCaseAttachment(attachemantFile, 4712,
252256
title='title 4713', description='descr. 4714')
253257

254258
def test_uploadAttachment_unknownID(self):
255-
attachemantFile = open(os.path.realpath(__file__), 'r')
259+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
256260
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
257261
self.client.uploadAttachment(attachemantFile, 4712, 'nodes_hierarchy',
258262
title='title 4713', description='descr. 4714')

test/utest-online/testlinkapicallservertest.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,51 @@
2929
class TestLinkAPIcallServerTestCase(unittest.TestCase):
3030
""" TestCases for TestLinkAPICleint._callServer() """
3131

32-
3332
def test_callServer_noArgs(self):
3433
""" test _callServer() - calling method with no args """
3534

3635
client = TestLinkHelper().connect(TestlinkAPIClient)
3736
response = client._callServer('sayHello')
3837
self.assertEqual('Hello!', response)
39-
38+
4039
def test_callServer_withArgs(self):
4140
""" test _callServer() - calling method with args """
4241

4342
client = TestLinkHelper().connect(TestlinkAPIClient)
44-
response = client._callServer('repeat', {'str' : 'some arg'})
43+
response = client._callServer('repeat', {'str': 'some arg'})
4544
self.assertEqual('You said: some arg', response)
46-
47-
def test_callServer_ProtocollError(self):
45+
46+
def test_callServer_ProtocolError(self):
4847
""" test _callServer() - Server raises ProtocollError """
4948

5049
server_url = TestLinkHelper()._server_url
5150
bad_server_url = server_url.split('xmlrpc.php')[0]
5251
client = TestLinkHelper(bad_server_url).connect(TestlinkAPIClient)
53-
def a_func(api_client): api_client._callServer('sayHello')
52+
53+
def a_func(api_client):
54+
api_client._callServer('sayHello')
5455
self.assertRaises(testlinkerrors.TLConnectionError, a_func, client)
55-
56+
5657
def test_callServer_socketError(self):
5758
""" test _callServer() - Server raises a socket Error (IOError) """
5859

5960
bad_server_url = 'http://111.222.333.4/testlink/lib/api/xmlrpc.php'
6061
client = TestLinkHelper(bad_server_url).connect(TestlinkAPIClient)
61-
def a_func(api_client): api_client._callServer('sayHello')
62+
63+
def a_func(api_client):
64+
api_client._callServer('sayHello')
6265
self.assertRaises(testlinkerrors.TLConnectionError, a_func, client)
6366

6467
def test_callServer_FaultError(self):
6568
""" test _callServer() - Server raises Fault Error """
6669

6770
client = TestLinkHelper().connect(TestlinkAPIClient)
68-
def a_func(api_client): api_client._callServer('sayGoodBye')
71+
72+
def a_func(api_client):
73+
api_client._callServer('sayGoodBye')
6974
self.assertRaises(testlinkerrors.TLAPIError, a_func, client)
7075

76+
7177
if __name__ == "__main__":
7278
#import sys;sys.argv = ['', 'Test.testName']
7379
unittest.main()

test/utest-online/testlinkapigeneric_online_test.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@
2828
# ok to check every implemented server call one time but not
2929
# to cover all possible responses or argument combinations
3030

31+
import sys
3132
import unittest, os.path
3233
from testlink import TestlinkAPIGeneric, TestLinkHelper
3334
from testlink.testlinkerrors import TLResponseError
3435

35-
import sys
36+
binary_read_mode = 'rb'
3637
if sys.version_info[0] < 3:
38+
binary_read_mode = 'r'
39+
if sys.version_info[1] < 7:
40+
import unittest2 as unittest
3741
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
3842

3943

40-
4144
class TestLinkAPIOnlineTestCase(unittest.TestCase):
4245
""" TestCases for TestlinkAPIClient - interacts with a TestLink Server.
4346
works with the example project NEW_PROJECT_API (see TestLinkExample.py)
@@ -191,7 +194,7 @@ def test_reportTCResult_unknownID(self):
191194
buildname='build 4713', notes='note 4714' )
192195

193196
def test_uploadExecutionAttachment_unknownID(self):
194-
attachemantFile = open(os.path.realpath(__file__), 'r')
197+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
195198
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
196199
self.client.uploadExecutionAttachment(attachemantFile, 4712,
197200
title='title 4713', description='descr. 4714')
@@ -231,45 +234,45 @@ def test_deleteTestCaseSteps_unknownID(self):
231234
self.client.deleteTestCaseSteps('N-4711', steps, version=1)
232235

233236
def test_uploadRequirementSpecificationAttachment_unknownID(self):
234-
attachemantFile = open(os.path.realpath(__file__), 'r')
237+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
235238
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
236239
self.client.uploadRequirementSpecificationAttachment(attachemantFile, 4712,
237240
title='title 4713', description='descr. 4714')
238241

239242
def test_uploadRequirementAttachment_unknownID(self):
240-
attachemantFile = open(os.path.realpath(__file__), 'r')
243+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
241244
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
242245
self.client.uploadRequirementAttachment(attachemantFile, 4712,
243246
title='title 4713', description='descr. 4714')
244247

245248
def test_uploadTestProjectAttachment_unknownID(self):
246-
attachemantFile = open(os.path.realpath(__file__), 'r')
249+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
247250
with self.assertRaisesRegex(TLResponseError, '7000.*4712'):
248251
self.client.uploadTestProjectAttachment(attachemantFile, 4712,
249252
title='title 4713', description='descr. 4714')
250253

251254
def test_uploadTestSuiteAttachment_unknownID(self):
252-
attachemantFile = open(os.path.realpath(__file__), 'r')
255+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
253256
with self.assertRaisesRegex(TLResponseError, '8000.*4712'):
254257
self.client.uploadTestSuiteAttachment(attachemantFile, 4712,
255258
title='title 4713', description='descr. 4714')
256259

257260
def test_uploadTestCaseAttachment_unknownID(self):
258-
attachemantFile = open(os.path.realpath(__file__), 'r')
261+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
259262
with self.assertRaisesRegex(TLResponseError, '5000.*testcaseid'):
260263
self.client.uploadTestCaseAttachment(attachemantFile, 4712,
261264
title='title 4713', description='descr. 4714')
262265

263266
def test_uploadAttachment_unknownID(self):
264-
attachemantFile = open(os.path.realpath(__file__), 'r')
267+
attachemantFile = open(os.path.realpath(__file__), binary_read_mode)
265268
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
266269
self.client.uploadAttachment(attachemantFile, 4712, 'nodes_hierarchy',
267270
title='title 4713', description='descr. 4714')
268-
271+
269272
def test_checkDevKey_unknownKey(self):
270273
with self.assertRaisesRegex(TLResponseError, '2000.*invalid'):
271274
self.client.checkDevKey(devKey='unknownKey')
272-
275+
273276
def test_testLinkVersion(self):
274277
response = self.client.testLinkVersion()
275278
self.assertRegex(response, '\d*\.\d*\.\d*')

0 commit comments

Comments
 (0)