@@ -296,10 +296,15 @@ def test_multiple_events_only_following_false(self):
296296
297297 @freeze_time ('2013-1-2' )
298298 def test_bulk_multiple_events_only_following_false (self ):
299+ """
300+ Handles bulk creating events and tests the unique constraint of the duplicated subscription which would cause
301+ a bulk create error if it wasn't handled
302+ """
299303 source = G (Source )
300304 e = G (Entity )
301305 other_e = G (Entity )
302306
307+ G (Subscription , entity = e , source = source , medium = self .email_medium , only_following = False )
303308 G (Subscription , entity = e , source = source , medium = self .email_medium , only_following = False )
304309 G (Subscription , entity = other_e , source = source , medium = self .email_medium , only_following = False )
305310 email_context = {
@@ -318,6 +323,35 @@ def test_bulk_multiple_events_only_following_false(self):
318323 self .assertEquals (email .subject , '' )
319324 self .assertEquals (email .scheduled , datetime (2013 , 1 , 2 ))
320325
326+ @freeze_time ('2013-1-2' )
327+ def test_bulk_multiple_events_only_following_true (self ):
328+ """
329+ Handles bulk creating events and tests the unique constraint of the duplicated subscription which would cause
330+ a bulk create error if it wasn't handled
331+ """
332+ source = G (Source )
333+ e = G (Entity )
334+ other_e = G (Entity )
335+
336+ G (Subscription , entity = e , source = source , medium = self .email_medium , only_following = True )
337+ G (Subscription , entity = e , source = source , medium = self .email_medium , only_following = True )
338+ G (Subscription , entity = other_e , source = source , medium = self .email_medium , only_following = True )
339+ email_context = {
340+ 'entity_emailer_template' : 'template' ,
341+ 'entity_emailer_subject' : 'hi' ,
342+ }
343+ G (Event , source = source , context = email_context )
344+ event = G (Event , source = source , context = email_context )
345+ G (EventActor , event = event , entity = e )
346+
347+ EntityEmailerInterface .bulk_convert_events_to_emails ()
348+
349+ email = Email .objects .get ()
350+ self .assertEquals (set (email .recipients .all ()), set ([e ]))
351+ self .assertEquals (email .event .context , email_context )
352+ self .assertEquals (email .subject , '' )
353+ self .assertEquals (email .scheduled , datetime (2013 , 1 , 2 ))
354+
321355 @freeze_time ('2013-1-2' )
322356 def test_multiple_events_only_following_true (self ):
323357 source = G (Source )
0 commit comments