Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-villavicencio-adsk committed Nov 26, 2024
1 parent 15fe99c commit 8d2eccc
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,63 @@ def test_invalid(self):

self.assertRaises(api.ShotgunError, api.shotgun._translate_filters, filters, "all")

def test_related_object(self):
filters = [
[
"project",
"is",
{"foo": "foo", "bar": "bar", "id": 999, "baz": "baz", "type": "Anything"},
],
]
expected = {
"logical_operator": "and",
"conditions": [
{
"path": "project",
"relation": "is",
"values": [
{
"foo": "foo",
"bar": "bar",
"baz": "baz",
"id": 999,
"type": "Anything",
}
],
}
],
}
result = api.shotgun._translate_filters(filters, "all")
self.assertEqual(result, expected)

def test_related_object_entity_optimization(self):
filters = [
[
"project",
"is",
{"foo": "foo", "bar": "bar", "id": 999, "baz": "baz", "type": "Anything"},
],
]
expected = {
"logical_operator": "and",
"conditions": [
{
"path": "project",
"relation": "is",
"values": [
{
"id": 999,
"type": "Anything",
}
],
}
],
}
os.environ["SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION"] = "1"
api.Shotgun("http://server_path", "script_name", "api_key", connect=False)
result = api.shotgun._translate_filters(filters, "all")
self.assertEqual(result, expected)


class TestCerts(unittest.TestCase):
# A dummy bad url provided by Amazon
Expand Down Expand Up @@ -506,5 +563,6 @@ def _test_mimetypes_import(self, platform, major, minor, patch_number, result, m
mock.platform = platform
self.assertEqual(_is_mimetypes_broken(), result)


if __name__ == '__main__':
unittest.main()

0 comments on commit 8d2eccc

Please sign in to comment.