PageRenderTime 36ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/regressiontests/comment_tests/tests/app_api_tests.py

https://code.google.com/p/mango-py/
Python | 71 lines | 70 code | 1 blank | 0 comment | 0 complexity | 1d74a93ebb9a3595c10d6e617bf1735f MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from django.conf import settings
  2. from django.contrib import comments
  3. from django.contrib.comments.models import Comment
  4. from django.contrib.comments.forms import CommentForm
  5. from regressiontests.comment_tests.tests import CommentTestCase
  6. class CommentAppAPITests(CommentTestCase):
  7. """Tests for the "comment app" API"""
  8. def testGetCommentApp(self):
  9. self.assertEqual(comments.get_comment_app(), comments)
  10. def testGetForm(self):
  11. self.assertEqual(comments.get_form(), CommentForm)
  12. def testGetFormTarget(self):
  13. self.assertEqual(comments.get_form_target(), "/post/")
  14. def testGetFlagURL(self):
  15. c = Comment(id=12345)
  16. self.assertEqual(comments.get_flag_url(c), "/flag/12345/")
  17. def getGetDeleteURL(self):
  18. c = Comment(id=12345)
  19. self.assertEqual(comments.get_delete_url(c), "/delete/12345/")
  20. def getGetApproveURL(self):
  21. c = Comment(id=12345)
  22. self.assertEqual(comments.get_approve_url(c), "/approve/12345/")
  23. class CustomCommentTest(CommentTestCase):
  24. urls = 'regressiontests.comment_tests.urls'
  25. def setUp(self):
  26. self.old_comments_app = getattr(settings, 'COMMENTS_APP', None)
  27. settings.COMMENTS_APP = 'regressiontests.comment_tests.custom_comments'
  28. settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + [settings.COMMENTS_APP,]
  29. def tearDown(self):
  30. del settings.INSTALLED_APPS[-1]
  31. settings.COMMENTS_APP = self.old_comments_app
  32. if settings.COMMENTS_APP is None:
  33. del settings._wrapped.COMMENTS_APP
  34. def testGetCommentApp(self):
  35. from regressiontests.comment_tests import custom_comments
  36. self.assertEqual(comments.get_comment_app(), custom_comments)
  37. def testGetModel(self):
  38. from regressiontests.comment_tests.custom_comments.models import CustomComment
  39. self.assertEqual(comments.get_model(), CustomComment)
  40. def testGetForm(self):
  41. from regressiontests.comment_tests.custom_comments.forms import CustomCommentForm
  42. self.assertEqual(comments.get_form(), CustomCommentForm)
  43. def testGetFormTarget(self):
  44. self.assertEqual(comments.get_form_target(), "/post/")
  45. def testGetFlagURL(self):
  46. c = Comment(id=12345)
  47. self.assertEqual(comments.get_flag_url(c), "/flag/12345/")
  48. def getGetDeleteURL(self):
  49. c = Comment(id=12345)
  50. self.assertEqual(comments.get_delete_url(c), "/delete/12345/")
  51. def getGetApproveURL(self):
  52. c = Comment(id=12345)
  53. self.assertEqual(comments.get_approve_url(c), "/approve/12345/")