Theseus007

Untitled

Feb 16th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2012-2015 by the Free Software Foundation, Inc.
  3. #
  4. # This file is part of Postorius.
  5. #
  6. # Postorius is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU General Public License as published by the Free
  8. # Software Foundation, either version 3 of the License, or (at your option)
  9. # any later version.
  10. # Postorius is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. # more details.
  14. #
  15. # You should have received a copy of the GNU General Public License along with
  16. # Postorius. If not, see <http://www.gnu.org/licenses/>.
  17.  
  18. import logging
  19.  
  20. from django.core.urlresolvers import reverse
  21. from django.test import Client, SimpleTestCase
  22. from django.test.utils import override_settings
  23. from urllib2 import HTTPError
  24.  
  25. from postorius.utils import get_client
  26. from postorius.tests import MM_VCR
  27.  
  28.  
  29. logger = logging.getLogger(__name__)
  30. vcr_log = logging.getLogger('vcr')
  31. vcr_log.setLevel(logging.WARNING)
  32.  
  33.  
  34. API_CREDENTIALS = {'MAILMAN_API_URL': 'http://localhost:9001',
  35. 'MAILMAN_USER': 'restadmin',
  36. 'MAILMAN_PASS': 'restpass'}
  37.  
  38.  
  39. @override_settings(**API_CREDENTIALS)
  40. class ListDeletePageTest(SimpleTestCase):
  41. """Tests for the list index page."""
  42.  
  43. @MM_VCR.use_cassette('test_list_index.yaml')
  44. def setUp(self):
  45. self.client = Client()
  46. try:
  47. self.domain = get_client().create_domain('example.com')
  48. except HTTPError:
  49. self.domain = get_client().get_domain('example.com')
  50. self.foo_list = self.domain.create_list('foo')
  51.  
  52.  
  53. @MM_VCR.use_cassette('test_list_index.yaml')
  54. def tearDown(self):
  55. for mlist in get_client().lists:
  56. mlist.delete()
  57.  
  58. @MM_VCR.use_cassette('test_list_index.yaml')
  59. def test_list_index_contains_one_list(self):
  60. # The list index page should contain the
  61. submit_response = self.client.get(reverse('list_delete',))
  62. self.assertEqual(response.status_code, 200)
  63. self.foo_list.delete()
  64. cancel_response = self.client.get(reverse('list_index',))
  65. self.assertEqual(cancel_response.status_code, 200)
  66. self.assertEqual(len(response.context['lists']), 0)
Advertisement
Add Comment
Please, Sign In to add comment