forked from shotgunsoftware/python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api_long.py
More file actions
89 lines (70 loc) · 3.28 KB
/
test_api_long.py
File metadata and controls
89 lines (70 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""Longer tests for calling the Shotgun API functions.
Includes the schema functions and the automated searching for all entity types
"""
import base
class TestShotgunApiLong(base.LiveTestBase):
def test_automated_find(self):
"""Called find for each entity type and read all fields"""
all_entities = self.sg.schema_entity_read().keys()
direction = "asc"
filter_operator = "all"
limit = 1
page = 1
for entity_type in all_entities:
if entity_type in ("Asset", "Task", "Shot", "Attachment",
"Candidate"):
continue
print "Finding entity type", entity_type
fields = self.sg.schema_field_read(entity_type)
if not fields:
print "No fields for %s skipping" % (entity_type,)
continue
#trying to use some different code paths to the other find test
#TODO for our test project, we haven't populated these entities....
order = [{'field_name': fields.keys()[0], 'direction': direction}]
if "project" in fields:
filters = [['project', 'is', self.project]]
else:
filters = []
records = self.sg.find(entity_type, filters, fields=fields.keys(),
order=order, filter_operator=filter_operator,
limit=limit, page=page)
self.assertTrue(isinstance(records, list))
if filter_operator == "all":
filter_operator = "any"
else:
filter_operator = "all"
if direction == "desc":
direction = "asc"
else:
direction = "desc"
limit = (limit % 5) + 1
page = (page % 3) + 1
def test_schema(self):
"""Called schema functions"""
schema = self.sg.schema_entity_read()
self.assertTrue(schema, dict)
self.assertTrue(len(schema) > 0)
schema = self.sg.schema_read()
self.assertTrue(schema, dict)
self.assertTrue(len(schema) > 0)
schema = self.sg.schema_field_read("Version")
self.assertTrue(schema, dict)
self.assertTrue(len(schema) > 0)
schema = self.sg.schema_field_read("Version", field_name="user")
self.assertTrue(schema, dict)
self.assertTrue(len(schema) > 0)
self.assertTrue("user" in schema)
properties = { "description" : "How many monkeys were needed" }
new_field_name = self.sg.schema_field_create("Version", "number",
"Monkey Count",
properties=properties)
properties = {"description" : "How many monkeys turned up"}
ret_val = self.sg.schema_field_update("Version",
new_field_name,
properties)
self.assertTrue(ret_val)
ret_val = self.sg.schema_field_delete("Version", new_field_name)
self.assertTrue(ret_val)
if __name__ == '__main__':
base.unittest.main()