#NEWLINE# def test_urgent_stockout_alert( self ) : #NEWLINE# #INDENT# urgent_stockout_alert = UrgentStockoutAlert ( TEST_DOMAIN ) #NEWLINE# urgent_stockout_alert . send ( ) #NEWLINE# self . assertEqual ( SMS . objects . count ( ) , 0 ) #NEWLINE# create_stock_report ( self . loc1 , { #NEWLINE# #INDENT# 'tp2' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# create_stock_report ( self . loc2 , { #NEWLINE# #INDENT# 'tp2' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# create_stock_report ( self . loc3 , { #NEWLINE# #INDENT# 'tp2' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# urgent_stockout_alert . send ( ) #NEWLINE# self . assertEqual ( SMS . objects . count ( ) , 1 ) #NEWLINE# self . assertEqual ( SMS . objects . all ( ) . first ( ) . text , ( URGENT_STOCKOUT % { #NEWLINE# #INDENT# 'location' : self . district . name , #NEWLINE# 'products' : 'Test Product2' , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# create_stock_report ( self . loc1 , { #NEWLINE# #INDENT# 'tp' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# create_stock_report ( self . loc2 , { #NEWLINE# #INDENT# 'tp' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# create_stock_report ( self . loc3 , { #NEWLINE# #INDENT# 'tp' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# now = datetime . utcnow ( ) #NEWLINE# urgent_stockout_alert . send ( ) #NEWLINE# smses = SMS . objects . filter ( date__gte = now ) #NEWLINE# self . assertEqual ( smses . count ( ) , 1 ) #NEWLINE# self . assertEqual ( smses . first ( ) . text , ( URGENT_STOCKOUT % { #NEWLINE# #INDENT# 'location' : self . district . name , #NEWLINE# 'products' : 'Test Product, Test Product2' , #NEWLINE# #UNINDENT# } ) )