Search code examples
kiwi-tcms

tcms api filters with date range


I'm trying to use tcms-api module with filter function.

https://tcms-api.readthedocs.io/en/latest/modules/tcms_api.html#module-tcms_api

I want to filter the result by date range, so collect the test cases between the date range, trying below code, but it's not working,

start_date = datetime.datetime(2021, 2, 8)
end_date = datetime.datetime(2021, 2, 9)

rpc_client = TCMS()

for test_case in rpc_client.exec.TestCase.filter({'create_date__range': '(start_date, end_date)'}):
    print(test_case)

I have tried different formats, also trying to refer to the following too, that not helps. https://docs.djangoproject.com/en/dev/ref/models/querysets/#range

Getting Following error,

  File "/usr/lib64/python3.6/xmlrpc/client.py", line 656, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32603: "Internal error: ['“(” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']">

How can this be used to filter the results based on date ranges?


Solution

  • rpc_client.exec.TestCase.filter({'create_date__range': '(start_date, end_date)'}):

    The value you pass should be a tuple, not a string so remove the quotes.

    Then there's a possibility that the XMLRPC serialization layer doesn't know how to encode this value but you will have to check it out. There could be a bug hiding somewhere in there.