<s> from django . conf import settings <EOL> from django . core import mail <EOL> from django . core . urlresolvers import reverse <EOL> from django . test import RequestFactory , TestCase <EOL> from django . test . utils import override_settings <EOL> from . . forms import ContactForm <EOL> @ override_settings ( ROOT_URLCONF = '<STR_LIT>' ) <EOL> class ContactFormViewTests ( TestCase ) : <EOL> def test_get ( self ) : <EOL> """<STR_LIT>""" <EOL> contact_url = reverse ( '<STR_LIT>' ) <EOL> response = self . client . get ( contact_url ) <EOL> self . assertEqual ( <NUM_LIT:200> , response . status_code ) <EOL> self . assertTemplateUsed ( response , <EOL> '<STR_LIT>' ) <EOL> def test_send ( self ) : <EOL> """<STR_LIT>""" <EOL> contact_url = reverse ( '<STR_LIT>' ) <EOL> data = { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT:body>' : '<STR_LIT>' } <EOL> response = self . client . post ( contact_url , <EOL> data = data ) <EOL> self . assertRedirects ( response , <EOL> reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( mail . outbox ) ) <EOL> message = mail . outbox [ <NUM_LIT:0> ] <EOL> self . assertTrue ( data [ '<STR_LIT:body>' ] in message . body ) <EOL> self . assertEqual ( settings . DEFAULT_FROM_EMAIL , <EOL> message . from_email ) <EOL> form = ContactForm ( request = RequestFactory ( ) . request ) <EOL> self . assertEqual ( form . recipient_list , <EOL> message . recipients ( ) ) <EOL> def test_invalid ( self ) : <EOL> """<STR_LIT>""" <EOL> contact_url = reverse ( '<STR_LIT>' ) <EOL> data = { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:body>' : '<STR_LIT>' } <EOL> response = self . client . post ( contact_url , <EOL> data = data ) <EOL> self . assertEqual ( <NUM_LIT:200> , response . status_code ) <EOL> self . assertFormError ( response , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:email>' , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( mail . outbox ) ) <EOL> def test_recipient_list ( self ) : <EOL> """<STR_LIT>""" <EOL> contact_url = reverse ( '<STR_LIT>' ) <EOL> data = { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT:body>' : '<STR_LIT>' } <EOL> response = self . client . post ( contact_url , <EOL> data = data ) <EOL> self . assertRedirects ( response , <EOL> reverse ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( mail . outbox ) ) <EOL> message = mail . outbox [ <NUM_LIT:0> ] <EOL> self . assertEqual ( [ '<STR_LIT>' ] , <EOL> message . recipients ( ) ) </s>
