@@ -1567,57 +1567,63 @@ class TestSessionTokenAuth(base.SessionTokenAuthLiveTestBase):
1567
1567
"""
1568
1568
Testing the session token based authentication method
1569
1569
"""
1570
-
1570
+
1571
1571
def test_humanuser_find (self ):
1572
1572
"""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' ]])
1576
1573
1577
- fields = [ 'id' ]
1574
+ if self . sg . server_caps . version >= ( 5 , 4 , 1 ):
1578
1575
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' ]])
1580
1579
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' ]
1585
1581
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" ])
1589
1592
1590
1593
def test_humanuser_upload_thumbnail_for_version (self ):
1591
1594
"""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
1596
1595
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 ):
1601
1597
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
1606
1602
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 ))
1609
1607
1608
+ # check result on version
1609
+ version_with_thumbnail = self .sg .find_one ('Version' ,
1610
+ [['id' , 'is' , self .version ['id' ]]],
1611
+ fields = ['image' ])
1610
1612
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' ])
1615
1615
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 )
1621
1627
1622
1628
1623
1629
class TestProjectLastAccessedByCurrentUser (base .LiveTestBase ):
0 commit comments