1212
1313import os
1414import unittest
15+ from unittest import mock
1516from .mock import patch
1617import shotgun_api3 as api
1718from shotgun_api3 .shotgun import _is_mimetypes_broken
@@ -434,7 +435,8 @@ def test_related_object(self):
434435 result = api .shotgun ._translate_filters (filters , "all" )
435436 self .assertEqual (result , expected )
436437
437- def test_related_object_entity_optimization (self ):
438+ @mock .patch .dict (os .environ , {"SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION" : "1" })
439+ def test_related_object_entity_optimization_is (self ):
438440 filters = [
439441 [
440442 "project" ,
@@ -457,7 +459,41 @@ def test_related_object_entity_optimization(self):
457459 }
458460 ],
459461 }
460- os .environ ["SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION" ] = "1"
462+ api .Shotgun ("http://server_path" , "script_name" , "api_key" , connect = False )
463+ result = api .shotgun ._translate_filters (filters , "all" )
464+ self .assertEqual (result , expected )
465+
466+ @mock .patch .dict (os .environ , {"SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION" : "1" })
467+ def test_related_object_entity_optimization_in (self ):
468+ filters = [
469+ [
470+ "project" ,
471+ "in" ,
472+ [
473+ {"foo1" : "foo1" , "bar1" : "bar1" , "id" : 999 , "baz1" : "baz1" , "type" : "Anything" },
474+ {"foo2" : "foo2" , "bar2" : "bar2" , "id" : 998 , "baz2" : "baz2" , "type" : "Anything" }
475+ ],
476+ ],
477+ ]
478+ expected = {
479+ "logical_operator" : "and" ,
480+ "conditions" : [
481+ {
482+ "path" : "project" ,
483+ "relation" : "in" ,
484+ "values" : [
485+ {
486+ "id" : 999 ,
487+ "type" : "Anything" ,
488+ },
489+ {
490+ "id" : 998 ,
491+ "type" : "Anything" ,
492+ }
493+ ],
494+ }
495+ ],
496+ }
461497 api .Shotgun ("http://server_path" , "script_name" , "api_key" , connect = False )
462498 result = api .shotgun ._translate_filters (filters , "all" )
463499 self .assertEqual (result , expected )
0 commit comments