shotgunsoftware/python-api

Mockgun does not support 'any' filter_operator

Closed this issue · 4 comments

mfe commented

When using an 'any' filter_operator and mocking, I get an :

Traceback (most recent call last):
  File "/home/marie/rdoenv/python_libs/pure/rodeo/tests/integration_tests/test_ilm_ocio_profile.py", line 121, in test_shotFilter
    for config in configs.shotConfigMap.iterkeys():
  File "/home/marie/rdoenv/python_libs/pure/rodeo/color/ilm_ocio_profile.py", line 122, in shotConfigMap
    for sgShot in self.sgShots:
  File "/home/marie/rdoenv/python_libs/pure/rodeo/color/ilm_ocio_profile.py", line 63, in sgShots
    self._sgShots = self.sg.find('Shot', queryFilters, ['code', 'sg_cdl_path', 'sg_client_name'])
  File "/home/marie/rdoenv/python_libs/pure/shotgun_api3/lib/mockgun.py", line 339, in find
    elif f[1] == "in" and not isinstance(f[2], list):
KeyError: 1

The same code is working when not mocking.

Code sample :

queryFilters = [['project.Project.code', 'is', self.projectCode],
                ['sg_status_list', 'not_in', ['bid', 'awd', 'omt', 'void', 'hdn']]
                ]

if self.shotFilters:
    # Keep only the shots that are corresponding to the filters
    shotQueryFilters = []
    for shotFilter in self.shotFilters:
        shotQueryFilters.append(['code', 'starts_with', shotFilter])
    queryFilters.append({
        "filter_operator": "any",
        "filters": shotQueryFilters
    })

self._sgShots = self.sg.find('Shot', queryFilters, ['code', 'sg_cdl_path', 'sg_client_name'])

Thanks !

Hi Marie, we are currently not supporting the filter_operator/filters syntax in Mockgun unfortunately. I'll make a feature request on our end.

Hi jfboismenu,

What is your proposed testing solution? I'm also running into this issue and occasionally people need to run an "OR" query in their code.

Hi @soylentplaid, sorry for the very late response. Unfortunately there is no alternative for testing. We have the same issue on the Toolkit side when writing unit tests and it bums us out too. We're hoping to be able to put in more work on Mockgun in the coming months, but unfortunately I can't give any time frame on when filter_operator support will be added.

Hi @mfe and @soylentplaid ,
We've just merged in master support in Mockgun for the filter_operator syntax. It should go out with the next official release of the Shotgun API. Let us know if you encounter any issues.