<s> from django . contrib . auth import get_user_model <EOL> from django . test import TestCase <EOL> from userena . contrib . umessages . models import Message , MessageRecipient , MessageContact <EOL> from userena . utils import truncate_words <EOL> User = get_user_model ( ) <EOL> class MessageContactTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def test_string_formatting ( self ) : <EOL> """<STR_LIT>""" <EOL> contact = MessageContact . objects . get ( pk = <NUM_LIT:1> ) <EOL> correct_format = "<STR_LIT>" <EOL> self . assertEqual ( contact . __str__ ( ) , <EOL> correct_format ) <EOL> def test_opposite_user ( self ) : <EOL> """<STR_LIT>""" <EOL> contact = MessageContact . objects . get ( pk = <NUM_LIT:1> ) <EOL> john = User . objects . get ( pk = <NUM_LIT:1> ) <EOL> jane = User . objects . get ( pk = <NUM_LIT:2> ) <EOL> self . assertEqual ( contact . opposite_user ( john ) , <EOL> jane ) <EOL> self . assertEqual ( contact . opposite_user ( jane ) , <EOL> john ) <EOL> class MessageModelTests ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def test_string_formatting ( self ) : <EOL> """<STR_LIT>""" <EOL> message = Message . objects . get ( pk = <NUM_LIT:1> ) <EOL> truncated_body = truncate_words ( message . body , <NUM_LIT:10> ) <EOL> self . assertEqual ( message . __str__ ( ) , <EOL> truncated_body ) <EOL> class MessageRecipientModelTest ( TestCase ) : <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def test_string_formatting ( self ) : <EOL> """<STR_LIT>""" <EOL> recipient = MessageRecipient . objects . get ( pk = <NUM_LIT:1> ) <EOL> valid_unicode = '<STR_LIT:%s>' % ( recipient . message ) <EOL> self . assertEqual ( recipient . __str__ ( ) , <EOL> valid_unicode ) <EOL> def test_new ( self ) : <EOL> """<STR_LIT>""" <EOL> new_message = MessageRecipient . objects . get ( pk = <NUM_LIT:1> ) <EOL> read_message = MessageRecipient . objects . get ( pk = <NUM_LIT:2> ) <EOL> self . assertTrue ( new_message . is_read ( ) ) <EOL> self . assertFalse ( read_message . is_read ( ) ) </s>
