Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_views.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. from django.contrib.auth.models import User
  2. from django.test.client import Client
  3. from django.test import TestCase
  4. try:
  5. from django.urls import reverse
  6. except ImportError:
  7. from django.core.urlresolvers import reverse
  8. from post_office import mail
  9. from post_office.models import Email
  10. admin_username = 'real_test_admin'
  11. admin_email = 'read@admin.com'
  12. admin_pass = 'admin_pass'
  13. class AdminViewTest(TestCase):
  14. def setUp(self):
  15. user = User.objects.create_superuser(admin_username, admin_email, admin_pass)
  16. self.client = Client()
  17. self.client.login(username=user.username, password=admin_pass)
  18. # Small test to make sure the admin interface is loaded
  19. def test_admin_interface(self):
  20. response = self.client.get(reverse('admin:index'))
  21. self.assertEqual(response.status_code, 200)
  22. def test_admin_change_page(self):
  23. """Ensure that changing an email object in admin works."""
  24. mail.send(recipients=['test@example.com'], headers={'foo': 'bar'})
  25. email = Email.objects.latest('id')
  26. response = self.client.get(reverse('admin:post_office_email_change', args=[email.id]))
  27. self.assertEqual(response.status_code, 200)