3
3
import unittest
4
4
from ConfigParser import ConfigParser
5
5
6
-
7
6
import mock
8
7
9
8
import shotgun_api3 as api
10
9
from shotgun_api3 .shotgun import json
11
10
from shotgun_api3 .shotgun import ServerCapabilities
12
11
12
+ import logging
13
+
13
14
CONFIG_PATH = 'tests/config'
14
15
15
16
class TestBase (unittest .TestCase ):
@@ -35,6 +36,10 @@ def __init__(self, *args, **kws):
35
36
36
37
37
38
def setUp (self , auth_mode = 'ApiUser' ):
39
+
40
+ self .LOG = logging .getLogger ("shotgun_api3" )
41
+ self .LOG .setLevel (logging .WARN )
42
+
38
43
self .config = SgTestConfig ()
39
44
self .config .read_config (CONFIG_PATH )
40
45
self .human_login = self .config .human_login
@@ -185,10 +190,14 @@ def _setup_mock_data(self):
185
190
186
191
class LiveTestBase (TestBase ):
187
192
'''Test base for tests relying on connection to server.'''
193
+
188
194
def setUp (self , auth_mode = 'ApiUser' ):
189
195
super (LiveTestBase , self ).setUp (auth_mode )
196
+
190
197
self .sg_version = self .sg .info ()['version' ][:3 ]
198
+
191
199
self ._setup_db (self .config )
200
+
192
201
if self .sg .server_caps .version and \
193
202
self .sg .server_caps .version >= (3 , 3 , 0 ) and \
194
203
(self .sg .server_caps .host .startswith ('0.0.0.0' ) or \
@@ -197,17 +206,22 @@ def setUp(self, auth_mode='ApiUser'):
197
206
else :
198
207
self .server_address = self .sg .server_caps .host
199
208
209
+
200
210
def _setup_db (self , config ):
201
211
data = {'name' :self .config .project_name }
202
212
self .project = _find_or_create_entity (self .sg , 'Project' , data )
203
213
214
+ self .template_project = _find_or_create_entity (self .sg , 'Project' , {
215
+ 'name' : 'Template Project' ,
216
+ 'is_template' : True
217
+ })
218
+
204
219
data = {'name' :self .config .human_name ,
205
220
'login' :self .config .human_login ,
206
221
'password_proxy' :self .config .human_password }
207
222
if self .sg_version >= (3 , 0 , 0 ):
208
223
data ['locked_until' ] = None
209
224
210
-
211
225
self .human_user = _find_or_create_entity (self .sg , 'HumanUser' , data )
212
226
213
227
data = {'code' :self .config .asset_code ,
@@ -256,6 +270,12 @@ def _setup_db(self, config):
256
270
keys = ['title' ,'project' , 'sg_priority' ]
257
271
self .ticket = _find_or_create_entity (self .sg , 'Ticket' , data , keys )
258
272
273
+ data = {'project' : self .template_project ,
274
+ 'title' : self .config .ticket_title ,
275
+ 'sg_priority' : '1' }
276
+ keys = ['title' , 'project' , 'sg_priority' ]
277
+ self .template_ticket = _find_or_create_entity (self .sg , 'Ticket' , data , keys )
278
+
259
279
keys = ['code' ]
260
280
data = {'code' :'api wrapper test storage' ,
261
281
'mac_path' :'nowhere' ,
0 commit comments