Skip to content

Commit bf17d42

Browse files
author
Luiko Czub
committed
api methdos for attachments #13
- uploadRequirementSpecificationAttachment, uploadRequirementAttachment - uploadTestProjectAttachment, uplodTestSuiteAttachment, uploadTestCaseAttachment - uploadAttachment
1 parent fc43ead commit bf17d42

File tree

7 files changed

+280
-39
lines changed

7 files changed

+280
-39
lines changed

CHANGES.rst

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,47 @@ TestLink-API-Python-client UNDER DEVELOP v0.4.7
55
-----------------------------------------------
66

77
new service methods - copy test cases #17
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
new TestlinkAPIClient service methods to copy test cases between test suites or
10+
to create a new test case version.
811

9-
TestlinkAPIClient delivers new method to copy test cases between test suites or
10-
to create a new test case version.
11-
12-
- copyTCnewVersion(origTestCaseId, **changedAttributes)
13-
- copyTCnewTestCase(origTestCaseId, **changedAttributes)
12+
- copyTCnewVersion(origTestCaseId, \*\*changedAttributes)
13+
- copyTCnewTestCase(origTestCaseId, \*\*changedAttributes)
1414
- getProjectIDByNode(a_nodeid)
1515

16-
implement missing 1.9.8 api methods - TestCase #11
16+
Example::
17+
18+
>>> import testlink
19+
>>> tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIClient)
20+
>>> tc_info = tls.getTestCase(None, testcaseexternalid='NPROAPI3-2')
21+
[{'full_tc_external_id': 'NPROAPI3-2', ..., 'id': '5440', 'version': '2',
22+
'testsuite_id': '5415', 'tc_external_id': '2','testcase_id': '5425', ...}]
23+
>>> tls.copyTCnewTestCase(tc_info[0]['testcase_id'], testsuiteid=newSuiteID,
24+
testcasename='a new test case name')
25+
26+
Known limitations:
27+
- estimatedexecduration settings are not copied
1728

29+
implement missing 1.9.8 api methods - TestCase #11
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1831
- addTestCaseToTestPlan, updateTestCase
1932
- createTestCaseSteps, deleteTestCaseSteps
2033

34+
implement missing 1.9.8 api methods - Attachments #13
35+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36+
- uploadRequirementSpecificationAttachment, uploadRequirementAttachment
37+
- uploadTestProjectAttachment, uplodTestSuiteAttachment
38+
- uploadTestCaseAttachment
39+
2140
TestLink-API-Python-client release notes v0.4.6 (Dec. 2013)
2241
-----------------------------------------------------------
2342

2443
TestLink-API-Python-client is now installable via PyPI #15
25-
44+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2645
pip install TestLink-API-Python-client
2746

2847
new api methods for Platforms implemented #10
29-
48+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3049
- createPlatform, getProjectPlatforms
3150
- addPlatformToTestPlan, removePlatformFromTestPlan
3251

example/TestLinkExample.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,15 @@
418418
# different filename 'MyPyExampleApiClient.py'
419419
a_file=open(NEWATTACHMENT_PY)
420420
newAttachment = myTestLink.uploadExecutionAttachment(a_file, newResultID_B,
421-
'Textfile Example', 'Text Attachment Example for a TestCase',
421+
'Textfile Example', 'Text Attachment Example for a TestCase Execution',
422422
filename='MyPyExampleApiClient.py')
423423
print "uploadExecutionAttachment", newAttachment
424424
# add png file as Attachemnt to last execution of TC_AA
425425
# !Attention - on WINDOWS use binary mode for none text file
426426
# see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
427427
a_file=open(NEWATTACHMENT_PNG, mode='rb')
428428
newAttachment = myTestLink.uploadExecutionAttachment(a_file, newResultID_AA,
429-
'PNG Example', 'PNG Attachment Example for a TestCase')
429+
'PNG Example', 'PNG Attachment Example for a TestCase Execution')
430430
print "uploadExecutionAttachment", newAttachment
431431

432432
# -- Create Build for TestPlan B (uses no platforms)
@@ -507,18 +507,29 @@
507507
response = myTestLink.getFullPath([int(newTestCaseID_AA), int(newTestCaseID_B)])
508508
print "getFullPath", response
509509

510-
# no test data
511-
# response = myTestLink.getTestCaseCustomFieldDesignValue(
512-
# tc_aa_full_ext_id, 1, newProjectID, 'cfieldname', 'simple')
513-
# print "getTestCaseCustomFieldDesignValue", response
514-
print "getTestCaseCustomFieldDesignValue", "Sorry currently no testdata"
515-
516-
# response = myTestLink.getTestCaseAttachments(None, testcaseexternalid=tc_aa_full_ext_id)
517-
# print "getTestCaseAttachments", response
518-
# response = myTestLink.getTestCaseAttachments(newTestCaseID_B)
510+
# attachments
511+
# add png file as Attachment to test project
512+
a_file=open(NEWATTACHMENT_PNG, mode='rb')
513+
newAttachment = myTestLink.uploadTestProjectAttachment(a_file, newProjectID,
514+
title='PNG Example', description='PNG Attachment Example for a TestProject')
515+
print "uploadTestProjectAttachment", newAttachment
516+
# add png file as Attachnent to test suite A
517+
a_file=open(NEWATTACHMENT_PNG, mode='rb')
518+
newAttachment = myTestLink.uploadTestSuiteAttachment(a_file, newTestSuiteID_A,
519+
title='PNG Example', description='PNG Attachment Example for a TestSuite')
520+
print "uploadTestSuiteAttachment", newAttachment
521+
# add png file as Attachment to test case B
522+
a_file=open(NEWATTACHMENT_PNG, mode='rb')
523+
newAttachment = myTestLink.uploadTestCaseAttachment(a_file, newTestCaseID_B,
524+
title='PNG Example', description='PNG Attachment Example for a TestCase')
525+
print "uploadTestCaseAttachment", newAttachment
526+
# get Attachment of test case B
527+
# response = myTestLink.getTestCaseAttachments(testcaseexternalid=tc_aa_full_ext_id)
519528
# print "getTestCaseAttachments", response
520-
print "getTestCaseAttachments", "Sorry currently no testdata"
529+
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B)
530+
print "getTestCaseAttachments", response
521531

532+
# copy test cases
522533
print "create new version of TC B"
523534
response = myTestLink.copyTCnewVersion(newTestCaseID_B,
524535
summary='new version of TC B', importance='1')
@@ -532,6 +543,19 @@
532543
response = myTestLink.getTestCasesForTestSuite(newTestSuiteID_A, True, 'simple')
533544
print 'getTestCasesForTestSuite A', response
534545

546+
# no test data
547+
# response = myTestLink.getTestCaseCustomFieldDesignValue(
548+
# tc_aa_full_ext_id, 1, newProjectID, 'cfieldname', 'simple')
549+
# print "getTestCaseCustomFieldDesignValue", response
550+
print "getTestCaseCustomFieldDesignValue", "Sorry currently no testdata"
551+
552+
# add png file as Attachemnt to a requirement specification.
553+
print "uploadRequirementSpecificationAttachment", "Sorry currently no testdata"
554+
# add png file as Attachemnt to a requirement.
555+
print "uploadRequirementAttachment", "Sorry currently no testdata"
556+
557+
558+
535559

536560
print ""
537561
print "Number of Projects in TestLink: %s " % myTestLink.countProjects()

example/TestLinkExampleGenericApi.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,15 @@
344344
# different filename 'MyPyExampleApiGeneric.py'
345345
a_file=open(NEWATTACHMENT_PY)
346346
newAttachment = myTestLink.uploadExecutionAttachment(a_file, newResultID_B,
347-
title='Textfile Example', description='Text Attachment Example for a TestCase',
347+
title='Textfile Example', description='Text Attachment Example for a TestCase Execution',
348348
filename='MyPyExampleApiGeneric.py')
349349
print "uploadExecutionAttachment", newAttachment
350350
# add png file as Attachemnt to last execution of TC_AA
351351
# !Attention - on WINDOWS use binary mode for none text file
352352
# see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
353353
a_file=open(NEWATTACHMENT_PNG, mode='rb')
354354
newAttachment = myTestLink.uploadExecutionAttachment(a_file, newResultID_AA,
355-
title='PNG Example', description='PNG Attachment Example for a TestCase')
355+
title='PNG Example', description='PNG Attachment Example for a TestCase Execution')
356356
print "uploadExecutionAttachment", newAttachment
357357

358358
# -- Create Build for TestPlan B (uses no platforms)
@@ -435,19 +435,38 @@
435435
response = myTestLink.getFullPath([int(newTestCaseID_AA), int(newTestCaseID_B)])
436436
print "getFullPath", response
437437

438+
# attachments
439+
# add png file as Attachment to test project
440+
a_file=open(NEWATTACHMENT_PNG, mode='rb')
441+
newAttachment = myTestLink.uploadTestProjectAttachment(a_file, newProjectID,
442+
title='PNG Example', description='PNG Attachment Example for a TestProject')
443+
print "uploadTestProjectAttachment", newAttachment
444+
# add png file as Attachnent to test suite A
445+
a_file=open(NEWATTACHMENT_PNG, mode='rb')
446+
newAttachment = myTestLink.uploadTestSuiteAttachment(a_file, newTestSuiteID_A,
447+
title='PNG Example', description='PNG Attachment Example for a TestSuite')
448+
print "uploadTestSuiteAttachment", newAttachment
449+
# add png file as Attachment to test case B
450+
a_file=open(NEWATTACHMENT_PNG, mode='rb')
451+
newAttachment = myTestLink.uploadTestCaseAttachment(a_file, newTestCaseID_B,
452+
title='PNG Example', description='PNG Attachment Example for a TestCase')
453+
print "uploadTestCaseAttachment", newAttachment
454+
# get Attachment of test case B
455+
# response = myTestLink.getTestCaseAttachments(testcaseexternalid=tc_aa_full_ext_id)
456+
# print "getTestCaseAttachments", response
457+
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B)
458+
print "getTestCaseAttachments", response
459+
438460
# no test data
439461
# response = myTestLink.getTestCaseCustomFieldDesignValue(
440462
# tc_aa_full_ext_id, 1, newProjectID, 'cfieldname', details='simple')
441463
# print "getTestCaseCustomFieldDesignValue", response
442464
print "getTestCaseCustomFieldDesignValue", "Sorry currently no testdata"
443465

444-
# response = myTestLink.getTestCaseAttachments(testcaseexternalid=tc_aa_full_ext_id)
445-
# print "getTestCaseAttachments", response
446-
# response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B)
447-
# print "getTestCaseAttachments", response
448-
print "getTestCaseAttachments", "Sorry currently no testdata"
449-
450-
466+
# add png file as Attachemnt to a requirement specification.
467+
print "uploadRequirementSpecificationAttachment", "Sorry currently no testdata"
468+
# add png file as Attachemnt to a requirement.
469+
print "uploadRequirementAttachment", "Sorry currently no testdata"
451470

452471
print ""
453472
print "Number of Projects in TestLink: %i " % len(myTestLink.getProjects())

src/testlink/testlinkapigeneric.py

Lines changed: 116 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,24 @@ def checkDevKey(self):
429429
# * returns the error map.
430430
# */
431431
# public function uploadRequirementSpecificationAttachment($args)
432+
433+
@decoApiCallAddAttachment
434+
@decoMakerApiCallWithArgs(['reqspecid'],
435+
['title', 'description', 'filename', 'filetype', 'content'])
436+
def uploadRequirementSpecificationAttachment(self):
437+
""" Uploads an attachment for a Requirement Specification.
438+
439+
reqspecid - The Requirement Specification ID
440+
441+
mandatory non api args: attachmentfile
442+
- python file descriptor pointing to the file
443+
- !Attention - on WINDOWS use binary mode for none text file
444+
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
445+
446+
default values for filename, filetype, content are determine from
447+
ATTACHMENTFILE, but user could overwrite it, if user want to store the
448+
attachment with a different name
449+
"""
432450

433451
# /**
434452
# * Uploads an attachment for a Requirement.
@@ -451,6 +469,25 @@ def checkDevKey(self):
451469
# */
452470
# public function uploadRequirementAttachment($args)
453471

472+
@decoApiCallAddAttachment
473+
@decoMakerApiCallWithArgs(['requirementid'],
474+
['title', 'description', 'filename', 'filetype', 'content'])
475+
def uploadRequirementAttachment(self):
476+
""" Uploads an attachment for a Requirement.
477+
478+
requirementid - The Requirement ID
479+
480+
mandatory non api args: attachmentfile
481+
- python file descriptor pointing to the file
482+
- !Attention - on WINDOWS use binary mode for none text file
483+
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
484+
485+
default values for filename, filetype, content are determine from
486+
ATTACHMENTFILE, but user could overwrite it, if user want to store the
487+
attachment with a different name
488+
"""
489+
490+
454491
# /**
455492
# * Uploads an attachment for a Test Project.
456493
# *
@@ -472,6 +509,24 @@ def checkDevKey(self):
472509
# */
473510
# public function uploadTestProjectAttachment($args)
474511

512+
@decoApiCallAddAttachment
513+
@decoMakerApiCallWithArgs(['testprojectid'],
514+
['title', 'description', 'filename', 'filetype', 'content'])
515+
def uploadTestProjectAttachment(self):
516+
""" Uploads an attachment for a Test Project.
517+
518+
testprojectid - The Test Project ID
519+
520+
mandatory non api args: attachmentfile
521+
- python file descriptor pointing to the file
522+
- !Attention - on WINDOWS use binary mode for none text file
523+
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
524+
525+
default values for filename, filetype, content are determine from
526+
ATTACHMENTFILE, but user could overwrite it, if user want to store the
527+
attachment with a different name
528+
"""
529+
475530
# /**
476531
# * Uploads an attachment for a Test Suite.
477532
# *
@@ -493,6 +548,24 @@ def checkDevKey(self):
493548
# */
494549
# public function uploadTestSuiteAttachment($args)
495550

551+
@decoApiCallAddAttachment
552+
@decoMakerApiCallWithArgs(['testsuiteid'],
553+
['title', 'description', 'filename', 'filetype', 'content'])
554+
def uploadTestSuiteAttachment(self):
555+
""" Uploads an attachment for a Test Suite.
556+
557+
testsuiteid - The Test Suite ID
558+
559+
mandatory non api args: attachmentfile
560+
- python file descriptor pointing to the file
561+
- !Attention - on WINDOWS use binary mode for none text file
562+
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
563+
564+
default values for filename, filetype, content are determine from
565+
ATTACHMENTFILE, but user could overwrite it, if user want to store the
566+
attachment with a different name
567+
"""
568+
496569
# /**
497570
# * Uploads an attachment for a Test Case.
498571
# *
@@ -514,20 +587,39 @@ def checkDevKey(self):
514587
# */
515588
# public function uploadTestCaseAttachment($args)
516589

590+
@decoApiCallAddAttachment
591+
@decoMakerApiCallWithArgs(['testcaseid'],
592+
['title', 'description', 'filename', 'filetype', 'content'])
593+
def uploadTestCaseAttachment(self):
594+
""" Uploads an attachment for a Test Case.
595+
596+
testcaseid - Test Case INTERNAL ID
597+
598+
mandatory non api args: attachmentfile
599+
- python file descriptor pointing to the file
600+
- !Attention - on WINDOWS use binary mode for none text file
601+
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
602+
603+
default values for filename, filetype, content are determine from
604+
ATTACHMENTFILE, but user could overwrite it, if user want to store the
605+
attachment with a different name
606+
"""
517607

518608
@decoApiCallAddAttachment
519609
@decoMakerApiCallWithArgs(['executionid'],
520610
['title', 'description', 'filename', 'filetype', 'content'])
521611
def uploadExecutionAttachment(self):
522612
""" Uploads an attachment for an execution
523-
mandatory non api args: attachmentfile
524613
525-
attachmentfile: python file descriptor pointing to the file
526-
!Attention - on WINDOWS use binary mode for none text file
527-
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
614+
executionid - execution ID
615+
616+
mandatory non api args: attachmentfile
617+
- python file descriptor pointing to the file
618+
- !Attention - on WINDOWS use binary mode for none text file
619+
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
528620
529621
default values for filename, filetype, content are determine from
530-
ATTACHMENTFILE, but user could overwrite it, if they want to store the
622+
ATTACHMENTFILE, but user could overwrite it, if user want to store the
531623
attachment with a different name
532624
"""
533625

@@ -556,6 +648,25 @@ def uploadExecutionAttachment(self):
556648
# */
557649
# public function uploadAttachment($args, $messagePrefix='', $setArgs=true)
558650

651+
@decoApiCallAddAttachment
652+
@decoMakerApiCallWithArgs(['fkid', 'fktable'],
653+
['title', 'description', 'filename', 'filetype', 'content'])
654+
def uploadAttachment(self):
655+
""" Uploads an attachment for an execution
656+
657+
fkid - The Attachment Foreign Key ID
658+
fktable - The Attachment Foreign Key Table
659+
660+
mandatory non api args: attachmentfile
661+
- python file descriptor pointing to the file
662+
- !Attention - on WINDOWS use binary mode for none text file
663+
see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
664+
665+
default values for filename, filetype, content are determine from
666+
ATTACHMENTFILE, but user could overwrite it, if user want to store the
667+
attachment with a different name
668+
"""
669+
559670
# /**
560671
# * Gets value of a Custom Field for a entity in a given scope (e.g.: a custom
561672
# * field for a test case in design scope).

src/testlink/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
#
1818
# ------------------------------------------------------------------------
1919

20-
VERSION = '0.4.7-dev-17'
20+
VERSION = '0.4.7-dev-13'

0 commit comments

Comments
 (0)