
from django.core.urlresolvers import resolve
from django.test import TestCase
from django.http import HttpRequest
from django.template.loader import render_to_string

from website.pages.views import home_page, send_email


class HomePageTest(TestCase):

    def test_root_url_resolves_to_home_page_view(self):
        found = resolve('/')
        self.assertEqual(found.func, home_page)

    def test_home_page_returns_correct_html(self):
        request = HttpRequest()
        response = home_page(request)
        expected_html = render_to_string('pages/home.html')

        self.assertEqual(response.content.decode(), expected_html)


class SendEmailTest(TestCase):

    def test_send_email_url_resolves_to_send_email_view(self):
        found = resolve('/send-email/')
        self.assertEqual(found.func, send_email)

    def test_send_email_returns_correct_html(self):
        request = HttpRequest()
        response = send_email(request)
        expected_html = render_to_string('pages/send_email.html')

        self.assertEqual(response.content.decode(), expected_html)


from django.core.urlresolvers import resolve
from django.test import TestCase
from django.http import HttpRequest
from django.template.loader import render_to_string

from website.pages.views import home_page, contact


class HomePageTest(TestCase):

    def test_root_url_resolves_to_home_page_view(self):
        found = resolve('/')
        self.assertEqual(found.func, home_page)

    def test_home_page_returns_correct_html(self):
        request = HttpRequest()
        response = home_page(request)
        expected_html = render_to_string('pages/home.html')

        self.assertEqual(response.content.decode(), expected_html)


class ContactTest(TestCase):

    def test_contact_url_resolves_to_contact_view(self):
        found = resolve('/contact/')
        self.assertEqual(found.func, contact)

    def test_contact_returns_correct_html(self):
        request = HttpRequest()
        response = contact(request)
        expected_html = render_to_string('pages/contact.html')

        self.assertEqual(response.content.decode(), expected_html)

Change send email to contact namespace
Change send email to contact namespace
  
  from django.core.urlresolvers import resolve
  from django.test import TestCase
  from django.http import HttpRequest
  from django.template.loader import render_to_string
  
- from website.pages.views import home_page, send_email
+ from website.pages.views import home_page, contact
  
  
  class HomePageTest(TestCase):
  
      def test_root_url_resolves_to_home_page_view(self):
          found = resolve('/')
          self.assertEqual(found.func, home_page)
  
      def test_home_page_returns_correct_html(self):
          request = HttpRequest()
          response = home_page(request)
          expected_html = render_to_string('pages/home.html')
  
          self.assertEqual(response.content.decode(), expected_html)
  
  
- class SendEmailTest(TestCase):
+ class ContactTest(TestCase):
  
-     def test_send_email_url_resolves_to_send_email_view(self):
+     def test_contact_url_resolves_to_contact_view(self):
-         found = resolve('/send-email/')
+         found = resolve('/contact/')
-         self.assertEqual(found.func, send_email)
+         self.assertEqual(found.func, contact)
  
-     def test_send_email_returns_correct_html(self):
+     def test_contact_returns_correct_html(self):
          request = HttpRequest()
-         response = send_email(request)
+         response = contact(request)
-         expected_html = render_to_string('pages/send_email.html')
+         expected_html = render_to_string('pages/contact.html')
  
          self.assertEqual(response.content.decode(), expected_html)
  
Change send email to contact namespace
## Code Before:

from django.core.urlresolvers import resolve
from django.test import TestCase
from django.http import HttpRequest
from django.template.loader import render_to_string

from website.pages.views import home_page, send_email


class HomePageTest(TestCase):

    def test_root_url_resolves_to_home_page_view(self):
        found = resolve('/')
        self.assertEqual(found.func, home_page)

    def test_home_page_returns_correct_html(self):
        request = HttpRequest()
        response = home_page(request)
        expected_html = render_to_string('pages/home.html')

        self.assertEqual(response.content.decode(), expected_html)


class SendEmailTest(TestCase):

    def test_send_email_url_resolves_to_send_email_view(self):
        found = resolve('/send-email/')
        self.assertEqual(found.func, send_email)

    def test_send_email_returns_correct_html(self):
        request = HttpRequest()
        response = send_email(request)
        expected_html = render_to_string('pages/send_email.html')

        self.assertEqual(response.content.decode(), expected_html)

## Instruction:
Change send email to contact namespace
## Code After:

from django.core.urlresolvers import resolve
from django.test import TestCase
from django.http import HttpRequest
from django.template.loader import render_to_string

from website.pages.views import home_page, contact


class HomePageTest(TestCase):

    def test_root_url_resolves_to_home_page_view(self):
        found = resolve('/')
        self.assertEqual(found.func, home_page)

    def test_home_page_returns_correct_html(self):
        request = HttpRequest()
        response = home_page(request)
        expected_html = render_to_string('pages/home.html')

        self.assertEqual(response.content.decode(), expected_html)


class ContactTest(TestCase):

    def test_contact_url_resolves_to_contact_view(self):
        found = resolve('/contact/')
        self.assertEqual(found.func, contact)

    def test_contact_returns_correct_html(self):
        request = HttpRequest()
        response = contact(request)
        expected_html = render_to_string('pages/contact.html')

        self.assertEqual(response.content.decode(), expected_html)
