Search code examples
kiwi-tcms

How to add component to a test case using API?


I created a test case using tcms_api

test_case = rpc_client.TestCase.create({
    'summary': 'My testing',
    'product': 2,
    'category': 2,
    'priority': 1,
    'is_automated': True,
    'text': 'my first test case',
    'case_status': 2,  # CONFIRMED
})

I wanted to add component to the test case, but could not find a sample or the syntax in API document. I tried the following with my guess and the update in change log:

rpc_client.TestCase.add_component(test_case['id'], [3, 6])

I got the error below. Can you please advise how to construct the query for component query? Thanks.

xmlrpc.client.Fault:

Fault -32603: 'Internal error: Component matching query does not exist.'


Solution

  • From the documentation the signature of this method is:

    function:: XML-RPC TestCase.add_component(case_id, component_id)
    

    The docs tell you that component_id is an int, not a list.

    ^^^^ scratch that, the documentation is slightly wrong.

    The second parameter is a string which should be the component name!