Skip to content

Is there any function to create keyword in test project? #152

@onesour

Description

@onesour

Hello,thanks for writing this library.It help me a lot to communicate with testlink.
My question is when I add a keyword which has not been created,it will response like this.
{'validKeywords': {'Auto01-4': ''}, 'status_ok': False}
So when the keyword not exist in project,I want to create this keyword.
But it seems to not have this kind of function.
Is there any way can deal with this problem?Or I need to send a API request directly to create keyword?
This is my sample code.

kw_to_add = ['keyword01','keyword02']
self.tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIClient)
case_more_info = self.tls.getTestCase(testcaseid=CASE_ID)[0]
kw_in_case = self.tls.getTestCaseKeywords(testcaseid=CASE_ID)
for kw in kw_to_add:
    if kw not in kw_in_case[CASE_ID]:
        insert_kw = {case_more_info['full_tc_external_id']: [kw]}
        add_kw_action = self.tls.addTestCaseKeywords(insert_kw)
        print(add_kw_action)

If keyword has existed in project,add_kw_action will be like:
{'validKeywords': {'Auto01-4': {'821': 'keyword01'}}, 'status_ok': True}
If keyword not exist,add_kw_action will be like:
{'validKeywords': {'Auto01-4': ''}, 'status_ok': False}

Sorry for my poor English.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions