<s> from nose . tools import eq_ <EOL> from kitsune . messages . models import InboxMessage , OutboxMessage <EOL> from kitsune . messages . utils import send_message <EOL> from kitsune . sumo . tests import TestCase <EOL> from kitsune . users . tests import UserFactory <EOL> class SendTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_send_message ( self ) : <EOL> to = UserFactory . create_batch ( <NUM_LIT:2> ) <EOL> sender = UserFactory ( ) <EOL> msg_text = "<STR_LIT>" <EOL> send_message ( to = to , text = msg_text , sender = sender ) <EOL> msgs_in = InboxMessage . objects . all ( ) <EOL> msgs_out = OutboxMessage . objects . all ( ) <EOL> eq_ ( <NUM_LIT:1> , msgs_out . count ( ) ) <EOL> msg_out = msgs_out [ <NUM_LIT:0> ] <EOL> eq_ ( sender , msg_out . sender ) <EOL> eq_ ( msg_text , msg_out . message ) <EOL> for u in msg_out . to . all ( ) : <EOL> assert u in to <EOL> eq_ ( <NUM_LIT:2> , msgs_in . count ( ) ) <EOL> for message in msgs_in : <EOL> eq_ ( sender , message . sender ) <EOL> assert message . to in to <EOL> eq_ ( msg_text , message . message ) </s>
