Permalink
Browse files

Added assert on context variable as suggested by @andrewschoen

  • Loading branch information...
1 parent 1ccc9e3 commit f91976828bcec2604e7fada95313e2859c196807 @yakky committed Jun 16, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 cms/tests/admin.py
View
@@ -416,6 +416,7 @@ def test_changelist_unquote(self):
response = pageadmin.changelist_view(request)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed("admin/cms/page/change_list.html")
+ self.assertEquals(response.context["open_menu_trees"], [1,2])
@beniwohli

beniwohli Jun 18, 2012

this triggers a failure for me:

ERROR: test_changelist_unquote (cms.tests.admin.AdminTestCase)
This test checks for proper jstree cookie unquoting.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/benjamin/projects/django-cms/cms/tests/admin.py", line 419, in test_changelist_unquote
    self.assertEquals(response.context["open_menu_trees"], [1,2])
AttributeError: 'HttpResponse' object has no attribute 'context'

response is a plain old HttpResponse instance in this case, since you are not using the django test client. Any other ideas how to test this?

@yakky

yakky via email Jun 18, 2012

Owner
@beniwohli

beniwohli Jun 19, 2012

Actually, both assertTemplateUsed and accessing response.context will not work in this case, because response is a normal HttpResponse, not a response from the test client.

The above failure is with Django 1.4. With 1,3, I get a different failure (not sure why 1.4 doesn't fail on this line already as well):

======================================================================
ERROR: test_changelist_unquote (cms.tests.admin.AdminTestCase)
This test checks for proper jstree cookie unquoting.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/benjamin/projects/django-cms/cms/tests/admin.py", line 418, in test_changelist_unquote
    self.assertTemplateUsed("admin/cms/page/change_list.html")
TypeError: assertTemplateUsed() takes at least 3 arguments (2 given)
class AdminFieldsetTests(TestCase):

0 comments on commit f919768

Please sign in to comment.