Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Adding SQL test case to testrail returns does not add SQL query


#1

I am tring to add the test cases programatically using the testrail API and the URI is add_case/:section_id using Python. It add the case with the title I provided in the data but does not add the SQL query. Following is the way I am trying to do that

from testrail import *

client = APIClient(TESTRAIL_URL)
client.user = TESTRAIL_USER
client.password = TESTRAIL_PASSWORD

section_id = MY_SECTION_ID
case_data = {
‘section_id’ : MY_SECTION_ID,
‘parent_id’: MY_CASE_PARENT_ID ,
‘title’ : ‘This test has to return a table’,
‘custom_sql’ : ‘SELECT * FROM MY_TABLE where col1 != ‘SOME CHAR’’,
‘custom_description’ : ‘This test has to return a table’,
}

response = client.send_post(‘add_case/{}’.format(int(section_id)), case_data)
print(response)

Getting the following response:

{‘id’: 1528, ‘title’: “This test has to return a table”, ‘section_id’: 250, ‘template_id’: 1, ‘type_id’: 7, ‘priority_id’: 2, ‘milestone_id’: None, ‘refs’: None, ‘created_by’: 79, ‘created_on’: 1540638265, ‘updated_by’: 79, ‘updated_on’: 1540638437, ‘estimate’: None, ‘estimate_forecast’: None, ‘suite_id’: 47, ‘custom_automation_type’: None, ‘custom_description’: None, ‘custom_preconds’: None, ‘custom_sql’: None, ‘custom_steps’: None, ‘custom_expected’: ‘0’, ‘custom_steps_separated’: None, ‘custom_mission’: None, ‘custom_goals’: None}

You can see that even I POST ‘custom_sql’ and ‘custom_description’ in my POST request but it still add None to that. But on the other hand it adds the case and title successfully. I tried to encode the string as UTF-8 but still didn’t work. Do any have any idea what I am doing wring here?