|Anonymous | Login | Signup for a new account||2019-10-19 16:10 UTC|
|Main | My View | View Issues | Change Log | My Account|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0001890||TestLink||API - XMLRPC||public||2008-11-19 22:13||2010-10-09 08:01|
|Product Version||1.8 RC 1|
|Fixed in Version||1.9 RC 1|
|Summary||0001890: Possibility to add attachment by using API|
would be very helpful to have the possibility to attachments by using the API. Maybe an enhancement for "reportTCResult".
|Tags||No tags attached.|
|QA Team - Task Workflow Status|
|Attached Files|| xmlrpc.class.php [^] (160,982 bytes) 2010-09-17 18:54|
tlAttachmentRepository.class.php [^] (16,148 bytes) 2010-09-17 18:54
testlinkunittests.zip [^] (5,249 bytes) 2010-09-17 18:54
|This should probably be put on the schedule for a post 1.8 release, possibly 1.9.|
OK, thanks for info. Currently i will pass them directly to db
(only a workaround ;-)).
Reminder sent to: austvik
I would like to know if you would like to contribute with this issue. If answer if yes write down here a technical anailys for this implementattion.
It is not on the top of my list, but if nobody beats me to it, this is how I would do it.
tl.reportTCResult returns the execution ID. I think we need one TL API call to add one attachment, and then this call could be used many times for each report ID if wanted.
I also see that the attachment code in TL is very general, so we should probably make this call general as well, but then the user/role/rights checking have to be good.
One new call:
attached_to_id (e.g. the id of the test execution)
attached_to_type (e.g. "executions", "node_hierarchy")
file_name (name of the file that is uploaded)
file_path (path of the file that is uploaded
data (the data in this attachment)
title (The title of this attachment, optional, default to file name)
description (Description of the content, optional, default to empty)
file_type (mime type of file, optional, defaults to application/octet-stream)
Then there is probably only a question of time before somebody asks for tl.getAttachments(attachment_to_type, attachment_to_id) => (attachment_id, file_name, file_path, tile_type, title, description) and tl.getAttachmentData(attachment_id) :)
1. on API getTestCaseAttachments() already exists.
2. new method addAttachment() will be used NOT ONLY to attach files to executions.
3. regarding other requests -> we will wait for it, right now is better to develop this one.
4. please use following names
instead of: attached_to_id => item_id
attached_to_type => item_type
5. why do we need:
file_name (name of the file that is uploaded)
file_path (path of the file that is uploaded
one parameter is not enough ? => pathname
6. how data will be encoded for transmission ? base64 ?
7. you need to provide also the sample PHP client to test this method.
4 + 5:
I started on this, and think that instead of item_id/item_type, it would be better to just set 'testcaseid', 'testplanid', 'testsuiteid', 'testprojectid', 'buildid', 'executionid' or 'platformid' (etc), then use the correct check* methods on them, and then connect to an element of that correct type.
6: Agree, XML RPL base64 looks like a good alternative.
I do not plan to work further on this until I know the full picture of how test execution is planned.
>> I started on this, and think that instead of item_id/item_type, it would be
>> better to just set 'testcaseid', 'testplanid', 'testsuiteid', 'testprojectid', >> 'buildid', 'executionid' or 'platformid' (etc), then use the correct check*
>> methods on them, and then connect to an element of that correct type.
We have used this approach on some areas of TL, to discover that is not a good approach, when the caller knows what is the type of item he is working on.
>> I do not plan to work further on this until I know the full picture of how
>> test execution is planned.
Hope other user will be willing to donate his time and contribute, no matter future direction of test execution will be.
Hi everybody. I would like to try to help with this issue. I am reading the source code, and some contributions that were submitted here in Mantis previously but worked only with execution.
Francisco, how's it going? I'd talked with you about TestLink Hudson plug-in. Thanks again for your support. Would you help me in this issue? Please (-:
I read this issue history. However after taking a look at the database model, I see two different approaches. In the first we implement something like: uploadAttachment($args) where args has fk_id, fk_table, attachment description, title and the $uploaddata (base64 encoded string). In the second approach we could implement different methods for each table, for e.g.: uploadExecutionAttachment(), uploadTestCaseAttachment(), and so it goes.
Which approach do you think we should use in the API?
BTW, if anybody see a different way of implementing the attachment upload function in the API, feel free to add suggestions (-:
>>uploadExecutionAttachment(), uploadTestCaseAttachment(), and so it goes.
but creating a wrapper around uploadAttachment($args).
hope explanation was clear
let me know if you are going to do this and if you want to contribute with TL, in order to plan reviews and future access to CVS
I got it, implement uploadAttachment and then methods that wrap the call to this method. Great idea. Should we let uploadAttachment available too? Or only the uploadExecutionAttachment, uploadTestCaseAttachment, etc?
I'm going to do this and contribute with TL. I'll add a patch to this issue as soon as I'm finished.
1. please attach full code no patch ( I prefer to do code review on full code)
>> I got it, implement uploadAttachment and then methods that wrap the call to
>> this method. Great idea. Should we let uploadAttachment available too? Or only >> the uploadExecutionAttachment, uploadTestCaseAttachment, etc?
expose also uploadAttachment(); this way people can use it without waiting for the 'verbose' method.
|Got it. Will get back here when I have some work done. Thanks Francisco.|
edited on: 2010-09-17 22:30
could somebody please review my code? It is been a long time I don't code in PHP, so I may be a little roasty in PHP now. It took a little while to upload my code because I am not used to the TestLink project yet. I didn't use the localization feature in the strings. Could somebody fix it (or show me how to make it (-:)? I also didn't know which role would have access right, so I used mgt_view_tc. Is it right? I tried keep the project standards, phpdoc comments and variable and api variables name format, however some thing may have passed.
I also uploaded the Java unit tests project that I used to test the upload feature. It uses maven and TestNG.
I didn't test a file that exceeds the maximum attachment size though. Sorry.
But I did test the parameters combination (missing content, missing foreign key, etc), enabling DataBase storage instead of FileSystem and GZip compression enabled.
I put a few TODO marks where I had doubts. I added an authenticate property to the api class to avoid double authentication. I don't know if it is the best option. What do you guys think about it?
I had to modify tlAttachmentRepository.class.php because it was using move_uploaded_file when TL was configured to store attachments in File System. I added an is_uploaded_file before this call and in case it is a non-uploaded file, I simply use rename.
The attachment content is being interpreted as Base64 encoded.
The implemented methods were:
All the above methods just wrap a call to uploadAttachment.
I will review your code
edited on: 2010-09-18 13:41
1. To allow traceability bewteen req and code changes
a. always add BUGID XXXX file header
b. function header
c. near pieces of code changed
2. Also add the developer signature -> email
3. do not use MAGIC CONSTANT -> if node type 1 is testproject, use existent
method to get form a descriptive node type name the node type code
Same apply on comments
4. lenght of code line < 100 chars
5. add new method at end of existent method this make diff the file easier
more to come (may be)
Thanks for reviewing it Francisco. I'm sorry for these mistakes, I've just checked TL site and found these instructions in the Developer Guide (great document, by the way). I'm going read it and try to follow the rules in my next contribution (-:
I forgot to add my mail, if you need it it's brunodepaulak at yahoo com br.
And about 4, I was trying to keep cyclomatic complexity and code lines short, however I missed some of it in the uploadAttachment method I guess. My bad (-: I'll pay more attention to this rule next time.
Thanks again for reviewing it.
1. thanks for you contribution
2. thanks for accepting the reviews
I've just committed code with some minor changes (you can give a look if you want)
I've added just one sample client written on PHP
I will consider this resolved ( I kwon I need to do more tests using PHP simple clients). I would apreciate if you can get last code and run yor automated test.
have a nice week end
|resolved with contributed code|
|Release 1.9 RC1|
|2008-11-19 22:13||partymungo||New Issue|
|2008-11-19 22:13||partymungo||Browser||=> Firefox 18.104.22.168|
|2008-11-20 04:59||azl||Status||new => assigned|
|2008-11-20 04:59||azl||Assigned To||=> azl|
|2008-11-20 05:01||azl||Note Added: 0004666|
|2008-11-20 15:48||partymungo||Note Added: 0004671|
|2010-04-05 14:58||fman||Note Added: 0009623|
|2010-04-05 17:57||austvik||Note Added: 0009625|
|2010-04-06 01:00||fman||Note Added: 0009628|
|2010-05-09 01:18||austvik||Note Added: 0009962|
|2010-05-09 16:40||fman||Note Added: 0009963|
|2010-05-09 16:41||fman||Assigned To||azl =>|
|2010-09-15 16:03||kinow||Note Added: 0011370|
|2010-09-15 16:04||kinow||Note Added: 0011371|
|2010-09-15 16:27||fman||Note Added: 0011372|
|2010-09-15 16:42||kinow||Note Added: 0011373|
|2010-09-15 17:02||fman||Note Added: 0011374|
|2010-09-15 23:04||kinow||Note Added: 0011381|
|2010-09-17 18:54||kinow||File Added: xmlrpc.class.php|
|2010-09-17 18:54||kinow||File Added: tlAttachmentRepository.class.php|
|2010-09-17 18:54||kinow||File Added: testlinkunittests.zip|
|2010-09-17 19:09||kinow||Note Added: 0011401|
|2010-09-17 22:28||kinow||Note Edited: 0011401||View Revisions|
|2010-09-17 22:30||kinow||Note Edited: 0011401||View Revisions|
|2010-09-18 06:29||fman||Note Added: 0011402|
|2010-09-18 06:29||fman||Assigned To||=> fman|
|2010-09-18 09:17||fman||Note Added: 0011407|
|2010-09-18 09:25||fman||Note Edited: 0011407||View Revisions|
|2010-09-18 13:22||fman||Note Edited: 0011407||View Revisions|
|2010-09-18 13:41||fman||Note Edited: 0011407||View Revisions|
|2010-09-18 13:43||kinow||Note Added: 0011408|
|2010-09-18 14:50||fman||Note Added: 0011409|
|2010-09-18 14:50||fman||Note Added: 0011410|
|2010-09-18 14:50||fman||Status||assigned => resolved|
|2010-09-18 14:50||fman||Fixed in Version||=> 1.9 RC 1|
|2010-09-18 14:50||fman||Resolution||open => fixed|
|2010-10-09 08:01||fman||Note Added: 0011759|
|2010-10-09 08:01||fman||Status||resolved => closed|
|2013-04-25 17:30||fman||Category||TL API => XMLRPC API|
|2013-04-25 17:30||fman||Category||XMLRPC API => API - XMLRPC|
|Copyright © 2000 - 2019 MantisBT Team|