@@ -1567,57 +1567,63 @@ class TestSessionTokenAuth(base.SessionTokenAuthLiveTestBase):
15671567 """
15681568 Testing the session token based authentication method
15691569 """
1570-
1570+
15711571 def test_humanuser_find (self ):
15721572 """Called find, find_one for known entities as session token based user"""
1573- filters = []
1574- filters .append (['project' , 'is' , self .project ])
1575- filters .append (['id' , 'is' , self .version ['id' ]])
15761573
1577- fields = [ 'id' ]
1574+ if self . sg . server_caps . version >= ( 5 , 4 , 1 ):
15781575
1579- versions = self .sg .find ("Version" , filters , fields = fields )
1576+ filters = []
1577+ filters .append (['project' , 'is' , self .project ])
1578+ filters .append (['id' , 'is' , self .version ['id' ]])
15801579
1581- self .assertTrue (isinstance (versions , list ))
1582- version = versions [0 ]
1583- self .assertEqual ("Version" , version ["type" ])
1584- self .assertEqual (self .version ['id' ], version ["id" ])
1580+ fields = ['id' ]
15851581
1586- version = self .sg .find_one ("Version" , filters , fields = fields )
1587- self .assertEqual ("Version" , version ["type" ])
1588- self .assertEqual (self .version ['id' ], version ["id" ])
1582+ versions = self .sg .find ("Version" , filters , fields = fields )
1583+
1584+ self .assertTrue (isinstance (versions , list ))
1585+ version = versions [0 ]
1586+ self .assertEqual ("Version" , version ["type" ])
1587+ self .assertEqual (self .version ['id' ], version ["id" ])
1588+
1589+ version = self .sg .find_one ("Version" , filters , fields = fields )
1590+ self .assertEqual ("Version" , version ["type" ])
1591+ self .assertEqual (self .version ['id' ], version ["id" ])
15891592
15901593 def test_humanuser_upload_thumbnail_for_version (self ):
15911594 """simple upload thumbnail for version test as session based token user."""
1592- this_dir , _ = os .path .split (__file__ )
1593- path = os .path .abspath (os .path .expanduser (
1594- os .path .join (this_dir ,"sg_logo.jpg" )))
1595- size = os .stat (path ).st_size
15961595
1597- # upload thumbnail
1598- thumb_id = self .sg .upload_thumbnail ("Version" ,
1599- self .version ['id' ], path )
1600- self .assertTrue (isinstance (thumb_id , int ))
1596+ if self .sg .server_caps .version >= (5 , 4 , 1 ):
16011597
1602- # check result on version
1603- version_with_thumbnail = self . sg . find_one ( 'Version' ,
1604- [[ 'id' , 'is' , self . version [ 'id' ]]],
1605- fields = [ 'image' ])
1598+ this_dir , _ = os . path . split ( __file__ )
1599+ path = os . path . abspath ( os . path . expanduser (
1600+ os . path . join ( this_dir , "sg_logo.jpg" )))
1601+ size = os . stat ( path ). st_size
16061602
1607- self .assertEqual (version_with_thumbnail .get ('type' ), 'Version' )
1608- self .assertEqual (version_with_thumbnail .get ('id' ), self .version ['id' ])
1603+ # upload thumbnail
1604+ thumb_id = self .sg .upload_thumbnail ("Version" ,
1605+ self .version ['id' ], path )
1606+ self .assertTrue (isinstance (thumb_id , int ))
16091607
1608+ # check result on version
1609+ version_with_thumbnail = self .sg .find_one ('Version' ,
1610+ [['id' , 'is' , self .version ['id' ]]],
1611+ fields = ['image' ])
16101612
1611- h = Http (".cache" )
1612- thumb_resp , content = h .request (version_with_thumbnail .get ('image' ), "GET" )
1613- self .assertEqual (thumb_resp ['status' ], '200' )
1614- self .assertEqual (thumb_resp ['content-type' ], 'image/jpeg' )
1613+ self .assertEqual (version_with_thumbnail .get ('type' ), 'Version' )
1614+ self .assertEqual (version_with_thumbnail .get ('id' ), self .version ['id' ])
16151615
1616- # clear thumbnail
1617- response_clear_thumbnail = self .sg .update ("Version" ,
1618- self .version ['id' ], {'image' :None })
1619- expected_clear_thumbnail = {'id' : self .version ['id' ], 'image' : None , 'type' : 'Version' }
1620- self .assertEqual (expected_clear_thumbnail , response_clear_thumbnail )
1616+
1617+ h = Http (".cache" )
1618+ thumb_resp , content = h .request (version_with_thumbnail .get ('image' ), "GET" )
1619+ self .assertEqual (thumb_resp ['status' ], '200' )
1620+ self .assertEqual (thumb_resp ['content-type' ], 'image/jpeg' )
1621+
1622+ # clear thumbnail
1623+ response_clear_thumbnail = self .sg .update ("Version" ,
1624+ self .version ['id' ], {'image' :None })
1625+ expected_clear_thumbnail = {'id' : self .version ['id' ], 'image' : None , 'type' : 'Version' }
1626+ self .assertEqual (expected_clear_thumbnail , response_clear_thumbnail )
16211627
16221628
16231629class TestProjectLastAccessedByCurrentUser (base .LiveTestBase ):
0 commit comments