Kanoah REST API with python

Raja kumar May 28, 2018

 

Need help in creating test run, attaching test results to test case with Kanoah REST API along with python.

 

Also I am not able to access the below given link . Can anyone provide some more detailed info . Kanoah API page shows few REST API's which doesn't provide the actual result.

https://kanoah.atlassian.net/login?redirectCount=1&dest-url=%2Fwiki%2Fdisplay%2FKT%2FManaging%2BTests%2BFrom%2Bthe%2BREST%2BAPI

3 answers

1 vote
Eric Lemay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 28, 2018

Which version are you using?  The current version of TM4J has its REST API documented here with an endpoint to add test results:

 

https://www.kanoah.com/docs/public-api/1.0/

 

But if you're using an older version the endpoint might not be present.

Raja kumar May 28, 2018

Thanks this what even I am looking for . Could you help with sample python code such that how these API's are used . Couldn't find any of those and its not the same as for JIRA REST API. 

Eric Lemay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 28, 2018

This rest API uses the existing JIRA framework for authentication and data, using json objects to update tests and result, the api docs show the data structure you'll need for those updates.  I unfrtunately don't have any sample python code.

Raja kumar May 28, 2018

from jira.client import JIRA

options={'server': 'https://jira.my_jira.com'}

jira=JIRA(options,basic_auth=('user', 'pass'))

root_dict = { 'project' : { 'key': 'project_name' },

                    'summary' : 'Test auto created issue',

                   'description' : 'Ignore this. will be deleted shortly',

                   'issuetype' : { 'name' : 'Task' },

                  }

my_issue= jira.create_issue(fields=root_dict)

The above is the code for creating an issue. We have create_issue method and hence we were able to create issue. But the same is not applicable with Kanoah API's since it cant be mentined Jira.testcase(fields) ==> to create a test case entry through API. 

This is my question basically how to use those API. Agreed with you for authentication we can use the existing JIRA framework. Need help in the last line on how to use those API's.

Eric Lemay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2018

Hello Raja, 

 

You're using the Jira.client python library.  that library only has the standard JIRA API and doesn't incorporate anything from addons, including TM4J.  You'd have to build your own connection management code to send the data and collect the response, but I'm not familiar with python so i'm afraid I can't help you there.

Raja kumar May 29, 2018

One last question could you just let me know what is TM4J (Expansion) . Why are you referencing it here. Apologize if this is basic , it would be clear if I get some more info on that like are there any python libraries for the same.

 

Thanks for the help.

Rajakumar

Eric Lemay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2018

Test Management for Jira (TM4J) is the new name for Kanoah Test Management which was renamed last year.

Raja kumar May 30, 2018

Ok Thank you !

0 votes
Raja kumar May 31, 2018

Sample code to attach,

files={'file':open(filename,'rb')}

response =requests.post(complete_url,auth=(user, password), files=files)

Sample code to create test run,

auth = BasicAuth(user, password)
resource = Resource(complete_url, filters=[auth])
try:
data = {

"name": "Test Run",
"projectKey": projectkey,
"status": "In Progress",
"items": [
{
"testCaseKey": testcasekey,
"userKey": user,
}
]

}

response =resource.post(headers={'Content-Type' : 'application/json'},payload=json.dumps(data))

0 votes
Raja kumar May 31, 2018

Thank you ! Using RESTKIT package we were able to create test run , test result.

Please find the restkit package link - https://pypi.org/project/restkit/2.2.2/.

Sample code to create testrun,

 

For attaching file to test result we couldnt find it through RESTKIT we used REQUESTS package for the same.

Sample code to attach file to test run is as follows,

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events