5
5
6
6
import base
7
7
8
+
8
9
class TestShotgunApiLong (base .LiveTestBase ):
9
-
10
+
10
11
def test_automated_find (self ):
11
12
"""Called find for each entity type and read all fields"""
12
13
all_entities = self .sg .schema_entity_read ().keys ()
@@ -24,66 +25,93 @@ def test_automated_find(self):
24
25
if not fields :
25
26
print "No fields for %s skipping" % (entity_type ,)
26
27
continue
27
-
28
- #trying to use some different code paths to the other find test
29
- #TODO for our test project, we haven't populated these entities....
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....
30
31
order = [{'field_name' : fields .keys ()[0 ], 'direction' : direction }]
31
32
if "project" in fields :
32
33
filters = [['project' , 'is' , self .project ]]
33
34
else :
34
35
filters = []
35
36
36
- records = self .sg .find (entity_type , filters , fields = fields .keys (),
37
+ records = self .sg .find (entity_type , filters , fields = fields .keys (),
37
38
order = order , filter_operator = filter_operator ,
38
39
limit = limit , page = page )
39
-
40
+
40
41
self .assertTrue (isinstance (records , list ))
41
-
42
+
42
43
if filter_operator == "all" :
43
44
filter_operator = "any"
44
- else :
45
+ else :
45
46
filter_operator = "all"
46
47
if direction == "desc" :
47
48
direction = "asc"
48
- else :
49
+ else :
49
50
direction = "desc"
50
51
limit = (limit % 5 ) + 1
51
52
page = (page % 3 ) + 1
52
-
53
53
54
54
def test_schema (self ):
55
55
"""Called schema functions"""
56
-
56
+
57
57
schema = self .sg .schema_entity_read ()
58
58
self .assertTrue (schema , dict )
59
59
self .assertTrue (len (schema ) > 0 )
60
60
61
61
schema = self .sg .schema_read ()
62
62
self .assertTrue (schema , dict )
63
63
self .assertTrue (len (schema ) > 0 )
64
-
64
+
65
65
schema = self .sg .schema_field_read ("Version" )
66
66
self .assertTrue (schema , dict )
67
67
self .assertTrue (len (schema ) > 0 )
68
-
68
+
69
69
schema = self .sg .schema_field_read ("Version" , field_name = "user" )
70
70
self .assertTrue (schema , dict )
71
71
self .assertTrue (len (schema ) > 0 )
72
72
self .assertTrue ("user" in schema )
73
-
74
- properties = { "description" : "How many monkeys were needed" }
75
- new_field_name = self .sg .schema_field_create ("Version" , "number" ,
76
- "Monkey Count" ,
73
+
74
+ properties = {"description" : "How many monkeys were needed" }
75
+ new_field_name = self .sg .schema_field_create ("Version" , "number" ,
76
+ "Monkey Count" ,
77
77
properties = properties )
78
-
79
- properties = {"description" : "How many monkeys turned up" }
78
+
79
+ properties = {"description" : "How many monkeys turned up" }
80
80
ret_val = self .sg .schema_field_update ("Version" ,
81
- new_field_name ,
82
- properties )
81
+ new_field_name ,
82
+ properties )
83
83
self .assertTrue (ret_val )
84
-
84
+
85
85
ret_val = self .sg .schema_field_delete ("Version" , new_field_name )
86
86
self .assertTrue (ret_val )
87
-
88
- if __name__ == '__main__' :
87
+
88
+ def test_schema_with_project (self ):
89
+ """Called schema functions"""
90
+
91
+ project_entity = {'type' : 'Project' , 'id' : 0 }
92
+ schema = self .sg .schema_entity_read (project_entity )
93
+ self .assertTrue (schema , dict )
94
+ self .assertTrue (len (schema ) > 0 )
95
+ self .assertTrue ('Project' in schema )
96
+ self .assertTrue ('visible' in schema ['Project' ])
97
+
98
+ schema = self .sg .schema_read (project_entity )
99
+ self .assertTrue (schema , dict )
100
+ self .assertTrue (len (schema ) > 0 )
101
+ self .assertTrue ('Version' in schema )
102
+
103
+ schema = self .sg .schema_field_read ('Version' , project_entity = project_entity )
104
+ self .assertTrue (schema , dict )
105
+ self .assertTrue (len (schema ) > 0 )
106
+ self .assertTrue ('user' in schema )
107
+ self .assertTrue ('visible' in schema ['user' ])
108
+
109
+ schema = self .sg .schema_field_read ('Version' , 'user' , project_entity )
110
+ self .assertTrue (schema , dict )
111
+ self .assertTrue (len (schema ) > 0 )
112
+ self .assertTrue ('user' in schema )
113
+ self .assertTrue ('visible' in schema ['user' ])
114
+
115
+
116
+ if __name__ == '__main__' :
89
117
base .unittest .main ()
0 commit comments