Olemis Lang avatar Olemis Lang committed 9cef6a2

BH Multiproduct #441 : Compatibility test case for products (delete)

Comments (0)

Files changed (1)

t441/t441_r1462483_product_module_pathinfo.diff

 
 diff -r 370dc3b4dd2e bloodhound_multiproduct/multiproduct/web_ui.py
 --- a/bloodhound_multiproduct/multiproduct/web_ui.py	Sat Mar 30 17:25:43 2013 -0500
-+++ b/bloodhound_multiproduct/multiproduct/web_ui.py	Sat Mar 30 22:35:23 2013 -0500
++++ b/bloodhound_multiproduct/multiproduct/web_ui.py	Sat Mar 30 22:45:38 2013 -0500
 @@ -36,7 +36,7 @@
  from multiproduct.model import Product
  from multiproduct.api import DEFAULT_PRODUCT
          return 'product_view.html', data, None
 diff -r 370dc3b4dd2e bloodhound_multiproduct/tests/web_ui.py
 --- a/bloodhound_multiproduct/tests/web_ui.py	Sat Mar 30 17:25:43 2013 -0500
-+++ b/bloodhound_multiproduct/tests/web_ui.py	Sat Mar 30 22:35:23 2013 -0500
-@@ -24,10 +24,14 @@
++++ b/bloodhound_multiproduct/tests/web_ui.py	Sat Mar 30 22:45:38 2013 -0500
+@@ -24,10 +24,15 @@
  
  from trac.core import Component, implements
  from trac.perm import PermissionCache, PermissionSystem
 -from trac.web.api import IRequestFilter, HTTPNotFound, Request
 +from trac.resource import ResourceNotFound
-+from trac.web.api import IRequestFilter, HTTPNotFound, Request, RequestDone
++from trac.web.api import HTTPInternalError, HTTPNotFound, IRequestFilter, \
++                         Request, RequestDone
 +from trac.web.href import Href
  from trac.web.main import RequestDispatcher
  
  from multiproduct.web_ui import ProductModule
  
  from tests.env import MultiproductTestCase
-@@ -59,14 +63,26 @@
+@@ -59,14 +64,26 @@
  class RequestHandlerTestCase(MultiproductTestCase):
      """Helper functions to write test cases for request handlers.
  
  
          req = Request(environ, start_response)
          return req
-@@ -75,6 +91,30 @@
+@@ -75,6 +92,30 @@
          req.perm = PermissionCache(env, req.authname)
          return RequestDispatcher(env).dispatch(req)
  
  
  #----------------
  # Testing product module
-@@ -89,7 +129,9 @@
+@@ -89,7 +130,9 @@
          self.global_env.enable_component(TestRequestSpy)
          self.env.enable_component(TestRequestSpy)
          TestRequestSpy(self.global_env).testMatch = self._assert_product_match
  
      def tearDown(self):
          self.global_env.reset_db()
-@@ -106,10 +148,10 @@
+@@ -106,10 +149,10 @@
                           "Unexpected sub path")
   
      def test_product_pathinfo_warning(self):
          req.authname = 'testuser'
          req.environ['PATH_INFO'] = '/products/PREFIX/some/path'
          self.expectedPrefix = 'PREFIX'
-@@ -122,6 +164,157 @@
+@@ -122,6 +165,172 @@
          self.assertEqual('Unable to render product page. Wrong setup ?',
                           test_cm.exception.detail)
  
 +        self.assertRedirect(req, product_url)
 +
 +    def test_product_delete(self):
-+        raise NotImplementedError()
++        spy = self.global_env[TestRequestSpy]
++        self.assertIsNot(None, spy)
++
++        req = self._get_request_obj(self.global_env)
++        req.authname = 'testuser'
++        req.environ['PATH_INFO'] = '/products/%s' % (self.default_product,)
++        req.environ['QUERY_STRING'] = 'action=delete'
++        self.expectedPrefix = self.default_product
++        self.expectedPathInfo = ''
++        spy.testProcessing = lambda *args, **kwargs: None
++
++        with self.assertRaises(HTTPInternalError) as test_cm:
++            self._dispatch(req, self.global_env)
++
++        self.assertEqual('500 Trac Error (Product removal is not allowed!)',
++                         unicode(test_cm.exception))
 +
  
  def test_suite():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.