6
6
import base
7
7
import random
8
8
9
+
9
10
class TestShotgunApiLong (base .LiveTestBase ):
10
-
11
+
11
12
def test_automated_find (self ):
12
13
"""Called find for each entity type and read all fields"""
13
14
all_entities = self .sg .schema_entity_read ().keys ()
@@ -25,57 +26,56 @@ def test_automated_find(self):
25
26
if not fields :
26
27
print "No fields for %s skipping" % (entity_type ,)
27
28
continue
28
-
29
- #trying to use some different code paths to the other find test
30
- #TODO for our test project, we haven't populated these entities....
29
+
30
+ # trying to use some different code paths to the other find test
31
+ # TODO for our test project, we haven't populated these entities....
31
32
order = [{'field_name' : fields .keys ()[0 ], 'direction' : direction }]
32
33
if "project" in fields :
33
34
filters = [['project' , 'is' , self .project ]]
34
35
else :
35
36
filters = []
36
37
37
- records = self .sg .find (entity_type , filters , fields = fields .keys (),
38
+ records = self .sg .find (entity_type , filters , fields = fields .keys (),
38
39
order = order , filter_operator = filter_operator ,
39
40
limit = limit , page = page )
40
-
41
+
41
42
self .assertTrue (isinstance (records , list ))
42
-
43
+
43
44
if filter_operator == "all" :
44
45
filter_operator = "any"
45
- else :
46
+ else :
46
47
filter_operator = "all"
47
48
if direction == "desc" :
48
49
direction = "asc"
49
- else :
50
+ else :
50
51
direction = "desc"
51
52
limit = (limit % 5 ) + 1
52
53
page = (page % 3 ) + 1
53
-
54
54
55
55
def test_schema (self ):
56
56
"""Called schema functions"""
57
-
57
+
58
58
schema = self .sg .schema_entity_read ()
59
59
self .assertTrue (schema , dict )
60
60
self .assertTrue (len (schema ) > 0 )
61
61
62
62
schema = self .sg .schema_read ()
63
63
self .assertTrue (schema , dict )
64
64
self .assertTrue (len (schema ) > 0 )
65
-
65
+
66
66
schema = self .sg .schema_field_read ("Version" )
67
67
self .assertTrue (schema , dict )
68
68
self .assertTrue (len (schema ) > 0 )
69
-
69
+
70
70
schema = self .sg .schema_field_read ("Version" , field_name = "user" )
71
71
self .assertTrue (schema , dict )
72
72
self .assertTrue (len (schema ) > 0 )
73
73
self .assertTrue ("user" in schema )
74
74
75
- # An explantion is in order here. the field code that is created in shotgun is based on the human display name
75
+ # An explanation is in order here. the field code that is created in shotgun is based on the human display name
76
76
# that is provided , so for example "Money Count" would generate the field code 'sg_monkey_count' . The field
77
77
# that is created in this test is retired at the end of the test but when this test is run again against
78
- # the same database ( which happens on our Continous Integration server ) trying to create a new field
78
+ # the same database ( which happens on our Continuous Integration server ) trying to create a new field
79
79
# called "Monkey Count" will now fail due to the new Delete Field Forever features we have added to shotgun
80
80
# since there will a retired field called sg_monkey_count. The old behavior was to go ahead and create a new
81
81
# "Monkey Count" field with a field code with an incremented number of the end like sg_monkey_count_1. The new
@@ -87,15 +87,43 @@ def test_schema(self):
87
87
properties = { "description" : "How many monkeys were needed" }
88
88
new_field_name = self .sg .schema_field_create ("Version" , "number" , human_field_name ,
89
89
properties = properties )
90
-
91
- properties = {"description" : "How many monkeys turned up" }
90
+
91
+ properties = {"description" : "How many monkeys turned up" }
92
92
ret_val = self .sg .schema_field_update ("Version" ,
93
- new_field_name ,
94
- properties )
93
+ new_field_name ,
94
+ properties )
95
95
self .assertTrue (ret_val )
96
-
96
+
97
97
ret_val = self .sg .schema_field_delete ("Version" , new_field_name )
98
98
self .assertTrue (ret_val )
99
-
100
- if __name__ == '__main__' :
99
+
100
+ def test_schema_with_project (self ):
101
+ """Called schema functions"""
102
+
103
+ project_entity = {'type' : 'Project' , 'id' : 0 }
104
+ schema = self .sg .schema_entity_read (project_entity )
105
+ self .assertTrue (schema , dict )
106
+ self .assertTrue (len (schema ) > 0 )
107
+ self .assertTrue ('Project' in schema )
108
+ self .assertTrue ('visible' in schema ['Project' ])
109
+
110
+ schema = self .sg .schema_read (project_entity )
111
+ self .assertTrue (schema , dict )
112
+ self .assertTrue (len (schema ) > 0 )
113
+ self .assertTrue ('Version' in schema )
114
+
115
+ schema = self .sg .schema_field_read ('Version' , project_entity = project_entity )
116
+ self .assertTrue (schema , dict )
117
+ self .assertTrue (len (schema ) > 0 )
118
+ self .assertTrue ('user' in schema )
119
+ self .assertTrue ('visible' in schema ['user' ])
120
+
121
+ schema = self .sg .schema_field_read ('Version' , 'user' , project_entity )
122
+ self .assertTrue (schema , dict )
123
+ self .assertTrue (len (schema ) > 0 )
124
+ self .assertTrue ('user' in schema )
125
+ self .assertTrue ('visible' in schema ['user' ])
126
+
127
+
128
+ if __name__ == '__main__' :
101
129
base .unittest .main ()
0 commit comments