Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed broken tests

  • Loading branch information...
commit fdaa984cf0ecd1ba907e23754cc3face9f351290 1 parent 4c136e4
@bfirsh bfirsh authored
View
133 class_based_views/tests/tests/base.py
@@ -31,41 +31,6 @@ def GET(self, request):
return unicode(hash(self))
-class JsonView(View):
- template_name = 'tests/apple_detail.html'
-
- def __init__(self, *args, **kwargs):
- super(JsonView, self).__init__(*args, **kwargs)
- self.allowed_formats.append('json')
- self.format_mimetypes['json'] = 'application/json'
-
- def render_json(self, request, *args, **kwargs):
- return simplejson.dumps(self.get_resource(request, *args, **kwargs))
-
- def get_resource(self, request, color='red', **kwargs):
- return {'apple': {
- 'color': color,
- }}
-
-
-class ContextArgsJsonView(JsonView):
- def get_context(self, request, extra='', **kwargs):
- context = super(ContextArgsJsonView, self).get_context(request)
- context['extra'] = extra
- return context
-
-
-class DefaultJsonView(JsonView):
- default_format = 'json'
-
-
-class ContextJsonView(JsonView):
- def get_context(self, request, *args, **kwargs):
- context = super(ContextJsonView, self).get_context(request, *args, **kwargs)
- context['tasty'] = True
- return context
-
-
class ViewTest(unittest.TestCase):
rf = RequestFactory()
@@ -122,101 +87,3 @@ def test_get_template_attribute(self):
"""
self._assert_about(AboutTemplateAttributeView()(self.rf.get('/about/')))
-# Broken
-class ResourceViewTest(unittest.TestCase):
- rf = RequestFactory()
-
- def _assert_html_apple(self, response):
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response['Content-type'], 'text/html')
- self.assertEqual(response.content, 'This is a red apple')
-
- def _assert_json_apple(self, response):
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response['Content-type'], 'application/json')
- self.assertEqual(
- simplejson.loads(response.content)['apple']['color'],
- 'red'
- )
-
- def test_json_default_html(self):
- """
- Test a view with different formats returns HTML by default.
- """
- self._assert_html_apple(JsonView()(self.rf.get('/apple/')))
-
- def test_json_view(self):
- """
- Test a view returns the correct format when explicitly set.
- """
- self._assert_json_apple(JsonView()(self.rf.get('/apple/?format=json')))
-
- def test_default_json_view(self):
- """
- Test a view that returns JSON by default.
- """
- self._assert_json_apple(DefaultJsonView()(self.rf.get('/apple/')))
-
- def test_default_json_view_html(self):
- """
- Test a view that returns JSON by default returns HTML if explicitly
- set.
- """
- self._assert_html_apple(DefaultJsonView()(
- self.rf.get('/apple/?format=html')
- ))
-
- def _assert_tasty(self, view):
- response = view(self.rf.get('/apple/'))
- self.assertEqual(response.content, 'This is a tasty red apple')
- response = view(self.rf.get('/apple/?format=json'))
- self.assertTrue(
- 'tasty' not in simplejson.loads(response.content)['apple']
- )
-
- def test_context_only_passed_to_template(self):
- """
- Test any extra context defined with ``get_context`` is only passed to
- templates.
- """
- self._assert_tasty(ContextJsonView())
-
- def test_context_processors(self):
- """
- Test any context processors defined are used to render the template.
- """
- self._assert_tasty(ContextProcessorJsonView())
-
- def test_resource_arguments(self):
- """
- Test any arguments from the URL are passed through to the resource.
- """
- response = JsonView()(self.rf.get('/apple/blue/'), color='blue')
- self.assertEqual(response.content, 'This is a blue apple')
-
- def test_context_arguments(self):
- """
- Test any arguments from the URL are passed through to the context.
- """
- response = ContextArgsJsonView()(
- self.rf.get('/apple/'),
- extra='. That is good'
- )
- self.assertEqual(
- response.content,
- 'This is a red apple. That is good'
- )
-
-# Broken
-class DecoratorViewTest(TestCase):
- urls = 'class_based_views.tests.urls'
-
- def test_decorators(self):
- """
- Test any decorators applied with the ``decorators`` attribute are
- applied.
- """
- res = self.client.get('/about/login-required/')
- self.assertEqual(res.status_code, 302)
- self.assertRedirects(res, 'http://testserver/accounts/login/?next=/about/login-required/')
-
View
5 class_based_views/tests/views.py
@@ -17,11 +17,6 @@ class AuthorDetail(class_based_views.DetailView):
queryset = Author.objects.all()
-class DecoratedAboutView(class_based_views.View):
- template_name = 'tests/about.html'
- decorators = [login_required,]
-
-
class DictList(class_based_views.ListView):
"""A ListView that doesn't use a model."""
queryset = [
Please sign in to comment.
Something went wrong with that request. Please try again.