Olemis Lang avatar Olemis Lang committed 068d5fe

BH RPC : Test cases for transferring product ownership via RPC

Comments (0)

Files changed (1)

trunk/bhrpc/tests/product.py

 
         check_products = self.admin.product.getAll()
 
-        self.assertEqual(['@', self.prefix], sorted(check_products))
+        self.assertEqual([DEFAULT_PRODUCT, self.prefix], sorted(check_products))
         self.assertEqual([self.prefix, 'new', 'new', 'admin'],
                          self.admin.product.get(self.prefix))
 
 
         self.anon.product.create(self.prefix + '2', 'test product', 'with owner', 'user')
         
-        self.assertEqual(['@', self.prefix + '2'], 
+        self.assertEqual([DEFAULT_PRODUCT, self.prefix + '2'], 
                          sorted(self.user.product.getAll()))
         self.assertEqual([self.prefix + '2', 'test product', 'with owner', 'user'],
                          self.user.product.get(self.prefix + '2'))
         self.assertEqual([self.prefix, 'test project', 'test change of description', 
                           'admin'], comp_product)
 
+    def test_chown(self):
+        """tests that ownership may be transferred by owner and admin only"""
+
+        self.admin.product.create(self.prefix, 'owned by user', 'transfer', 
+                                  'user')
+        self.assertEqual([DEFAULT, self.prefix], self.admin.product.getAll())
+
+        self.user.product.chown(self.prefix, 'somebody')
+        self.assertEqual([self.prefix, 'owned by user', 'transfer', 'somebody'],
+                         self.admin.product.get(self.prefix()))
+
+        self.admin.product.chown(self.prefix, 'nobody')
+        self.assertEqual([self.prefix, 'owned by user', 'transfer', 'admin'],
+                         self.admin.product.get(self.prefix()))
+
+        self.anon.product.chown(self.prefix, 'nobody')
+        self.assertEqual([self.prefix, 'owned by user', 'transfer', 'admin'],
+                         self.admin.product.get(self.prefix()))
+
+    def test_chown(self):
+        """tests that ownership may not be transferred to anonymous"""
+
+        self.admin.product.create(self.prefix, 'no anonymous', 'transfer fail')
+
+        with self.assertRaises(xmlrpclib.Fault) as test_cm:
+            self.admin.product.chown(self.prefix, 'anonymous')
+        self.assertEqual(1, test_cm.exception.faultCode)
+        self.assertEquals("'Product owner must be specified' while executing "
+                          "'product.chown()'",
+                          test_cm.exception.faultString)
+
+        with self.assertRaises(xmlrpclib.Fault) as test_cm:
+            self.admin.product.chown(self.prefix, '')
+        self.assertEqual(1, test_cm.exception.faultCode)
+        self.assertEquals("'Product owner must be specified' while executing "
+                          "'product.chown()'",
+                          test_cm.exception.faultString)
+
+
 class RpcGlobalProductTestCase(RpcProductTestCase):
     """Test product API in global scope
     """
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.