Search code examples
kiwi-tcms

Can add author filed when import test case via api interface?


I import a test case into Kiwi TCMS via API interface, find Author filed is “Admin”. I want to add author filed. I add an “author” key and with a value in values dict. But author is still displayed as Admin.

I use the following API:

 rpc_client = tcms_api.TCMS()._server
 rpc_client.Auth.login('admin', 'admin')
 self.rpc_client.TestCase.create(values)

Solution

  • Friendly warning:

    self.rpc_client.TestCase.create(values)

    this is a bit old, you are using an older version of Kiwi TCMS.

    The new syntax (compatible with latest versions, see changelog) is:

    rpc_client = tcms_api.TCMS() rpc_client.exec.TestCase.create(values)

    without the need to Auth.login() first. The API client will do this for you.

    To answer the question. Inside of tcms/xmlrpc/api/testcase.py::create() we have:

    test_case = TestCase.create(author=request.user, values=form.cleaned_data)

    The author is always the user that sends the API request, which is the same behavior when creating Test Case via the webUI.

    If you want a different user, either configure your API client with another username.

    You may also try the TestCase.update() API method but ATM this doesn't allow you to update the author. Please open an issue on GitHub if you want this functionality to be present (sounds like a valid use-case).