@@ -426,7 +426,7 @@ def test_deprecated_functions(self):
426426
427427
428428 def test_simple_summary (self ):
429- '''test_simple_summary tests simple query using summarize.'''
429+ """Test simple call to summarize"""
430430 summaries = [{'field' : 'id' , 'type' : 'count' }]
431431 grouping = [{'direction' : 'asc' , 'field' : 'id' , 'type' : 'exact' }]
432432 filters = [['project' , 'is' , self .project ]]
@@ -441,6 +441,7 @@ def test_simple_summary(self):
441441 assert (result ['summaries' ])
442442
443443 def test_summary_include_archived_projects (self ):
444+ """Test summarize with archived project"""
444445 if self .sg .server_caps .version > (5 , 3 , 13 ):
445446 # archive project
446447 self .sg .update ('Project' , self .project ['id' ], {'archived' :True })
@@ -457,32 +458,54 @@ def test_summary_include_archived_projects(self):
457458 self .sg .update ('Project' , self .project ['id' ], {'archived' :False })
458459
459460 def test_summary_values (self ):
460- ''''''
461- # try to fix data if not in expected state
462- shots = self .sg .find ('Shot' ,[['project' ,'is' ,self .project ],['code' ,'in' ,['shot 1' ,'shot 2' ,'shot 3' ]]])
463- print len (shots )
464- for shot in shots :
465- # These shots should have been deleted,if they still exist it is due to an failure in mid-test
466- self .sg .delete ('Shot' , shot ['id' ])
467-
468-
469- shot_data = {
470- 'sg_status_list' : 'ip' ,
471- 'sg_cut_duration' : 100 ,
472- 'project' : self .project
473- }
461+ """Test summarize return data"""
462+
463+ # create three unique shots
464+ shot_prefix = uuid .uuid4 ().hex
465+
474466 shots = []
475- shots .append (self .sg .create ('Shot' , dict (shot_data .items () +
476- {'code' : 'shot 1' }.items ())))
477- shots .append (self .sg .create ('Shot' , dict (shot_data .items () +
478- {'code' : 'shot 2' }.items ())))
479- shots .append (self .sg .create ('Shot' , dict (shot_data .items () +
480- {'code' : 'shot 3' ,
481- 'sg_status_list' : 'fin' }.items ())))
467+
468+ shot_data_1 = {
469+ "code" : "%s Shot 1" % shot_prefix ,
470+ "sg_status_list" : "ip" ,
471+ "sg_cut_duration" : 100 ,
472+ "project" : self .project
473+ }
474+
475+ shot_data_2 = {
476+ "code" : "%s Shot 2" % shot_prefix ,
477+ "sg_status_list" : "ip" ,
478+ "sg_cut_duration" : 100 ,
479+ "project" : self .project
480+ }
481+
482+ shot_data_3 = {
483+ "code" : "%s Shot 3" % shot_prefix ,
484+ "sg_status_list" : "fin" ,
485+ "sg_cut_duration" : 100 ,
486+ "project" : self .project
487+ }
488+
489+ shot_data_4 = {
490+ "code" : "%s Shot 4" % shot_prefix ,
491+ "sg_status_list" : "wtg" ,
492+ "sg_cut_duration" : 0 ,
493+ "project" : self .project
494+ }
495+
496+ shots .append (self .sg .create ("Shot" , shot_data_1 ))
497+ shots .append (self .sg .create ("Shot" , shot_data_2 ))
498+ shots .append (self .sg .create ("Shot" , shot_data_3 ))
499+ shots .append (self .sg .create ("Shot" , shot_data_4 ))
500+
501+
482502 summaries = [{'field' : 'id' , 'type' : 'count' },
483503 {'field' : 'sg_cut_duration' , 'type' : 'sum' }]
484- grouping = [{'direction' : 'asc' , 'field' : 'sg_status_list' , 'type' : 'exact' }]
485- filters = [['project' , 'is' , self .project ]]
504+ grouping = [{'direction' : 'asc' ,
505+ 'field' : 'sg_status_list' ,
506+ 'type' : 'exact' }]
507+ filters = [['project' , 'is' , self .project ],
508+ ['code' , 'starts_with' , shot_prefix ]]
486509 result = self .sg .summarize ('Shot' ,
487510 filters = filters ,
488511 summary_fields = summaries ,
@@ -510,7 +533,7 @@ def test_summary_values(self):
510533 for s in shots :
511534 batch_data .append ({"request_type" : "delete" ,
512535 "entity_type" : "Shot" ,
513- "entity_id" : s ['id' ]
536+ "entity_id" : s ["id" ]
514537 })
515538 self .sg .batch (batch_data )
516539
@@ -1715,6 +1738,20 @@ def setUp(self):
17151738 "project" : self .project ,
17161739 "note_links" : [self ._shot ]})
17171740
1741+ def tearDown (self ):
1742+ batch_data = []
1743+ batch_data .append ({"request_type" : "delete" ,
1744+ "entity_type" : self ._note ["type" ],
1745+ "entity_id" : self ._note ["id" ]
1746+ })
1747+ batch_data .append ({"request_type" : "delete" ,
1748+ "entity_type" : self ._shot ["type" ],
1749+ "entity_id" : self ._shot ["id" ]
1750+ })
1751+ self .sg .batch (batch_data )
1752+
1753+ super (TestActivityStream , self ).tearDown ()
1754+
17181755 def test_simple (self ):
17191756 """
17201757 Test activity stream
@@ -1814,6 +1851,11 @@ def _check_reply(self, data, reply_id, additional_fields):
18141851 reply_data = self .sg .find_one ("Reply" ,
18151852 [["id" , "is" , reply_id ]],
18161853 list (expected_fields ))
1854+
1855+ # the reply stream adds an image to the user fields in order
1856+ # to include thumbnails for users, so add this in before we compare
1857+ reply_data ["user" ]["image" ] = None
1858+
18171859 self .assertEqual (reply_data , data )
18181860
18191861 def _check_attachment (self , data , attachment_id , additional_fields ):
@@ -1823,11 +1865,11 @@ def _check_attachment(self, data, attachment_id, additional_fields):
18231865 self .assertEqual (expected_fields , set (data .keys ()))
18241866
18251867 # check that the data matches the data we get from a find call
1826- reply_data = self .sg .find_one ("Attachment" ,
1827- [["id" , "is" , attachment_id ]],
1828- list (expected_fields ))
1868+ attachment_data = self .sg .find_one ("Attachment" ,
1869+ [["id" , "is" , attachment_id ]],
1870+ list (expected_fields ))
18291871
1830- self .assertEqual (reply_data , data )
1872+ self .assertEqual (attachment_data , data )
18311873
18321874 def test_simple (self ):
18331875 """
@@ -1940,6 +1982,24 @@ def setUp(self):
19401982 self ._shot_ids = [x ["id" ] for x in data if x ["type" ] == "Shot" ]
19411983 self ._asset_ids = [x ["id" ] for x in data if x ["type" ] == "Asset" ]
19421984
1985+ def tearDown (self ):
1986+
1987+ # clean up
1988+ batch_data = []
1989+ for shot_id in self ._shot_ids :
1990+ batch_data .append ({"request_type" : "delete" ,
1991+ "entity_type" : "Shot" ,
1992+ "entity_id" : shot_id
1993+ })
1994+ for asset_id in self ._asset_ids :
1995+ batch_data .append ({"request_type" : "delete" ,
1996+ "entity_type" : "Asset" ,
1997+ "entity_id" : asset_id
1998+ })
1999+ self .sg .batch (batch_data )
2000+
2001+ super (TestTextSearch , self ).tearDown ()
2002+
19432003 def test_simple (self ):
19442004 """
19452005 Test basic global search
0 commit comments