Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import httplib
  2. from django.test import TestCase
  3. from django.test.client import Client
  4. from django.core.urlresolvers import reverse
  5. from django.contrib.auth.models import User
  6. class ViewTests(TestCase):
  7. def setUp(self):
  8. self.client = Client()
  9. class AnonymousUserTests(ViewTests):
  10. def test_login_form_is_displayed_for_anon_user(self):
  11. response = self.client.get(reverse('dashboard:index'))
  12. self.assertTrue('Username' in response.content)
  13. class StaffViewTests(ViewTests):
  14. def setUp(self):
  15. super(StaffViewTests, self).setUp()
  16. user = User.objects.create_user('staffperson', 'staff@example.com', 'staffpassword')
  17. user.is_staff = True
  18. user.save()
  19. self.client.login(username='staffperson', password='staffpassword')
  20. class DashboardViewTests(StaffViewTests):
  21. def test_dashboard_index_is_for_staff_only(self):
  22. urls = ('dashboard:index',
  23. 'dashboard:orders',)
  24. for name in urls:
  25. response = self.client.get(reverse(name))
  26. self.assertTrue('Username' not in response.content)
  27. class OrderListTests(StaffViewTests):
  28. def test_searching_for_valid_order_number_redirects_to_order_page(self):
  29. pass