Author: janguenot
Date: Wed Oct  5 15:16:57 2005
New Revision: 27967

Modified:
   z3lab/Zope3Benchs/trunk/test_Zope3.py
Log:
Fix read tests by fetching a buddy folder randomly and viewing the contents

Modified: z3lab/Zope3Benchs/trunk/test_Zope3.py
==============================================================================
--- z3lab/Zope3Benchs/trunk/test_Zope3.py       (original)
+++ z3lab/Zope3Benchs/trunk/test_Zope3.py       Wed Oct  5 15:16:57 2005
@@ -20,7 +20,8 @@
 $Id$
 """
 import unittest
-from random import random
+import random
+
 from funkload.FunkLoadTestCase import FunkLoadTestCase
 from funkload.Lipsum import Lipsum
 
@@ -72,6 +73,11 @@
         self.setBasicAuth(self.member_id, self.member_pwd)
         self.get("%s/" % server_url, description="Zope3 default page")
 
+    def _genBuddyFolderId(self):
+        """Generate an id for a buddy folder
+        """
+        return 'buddy_folder_' + self._lipsum.getUniqWord()
+
     def test_00_BuddyDemoApp_RW(self):
         """Test the buddy demo application.
 
@@ -95,7 +101,7 @@
         while j < int(nb_buddies_folder):
 
             # Create the buddies folder
-            buddies_folder_id = self._lipsum.getUniqWord()
+            buddies_folder_id = self._genBuddyFolderId()
             params = [
                 ['type_name', 'BrowserAdd__buddydemo.buddy.BuddyFolder'],
                 ['id', buddies_folder_id],
@@ -177,25 +183,34 @@
 
             j += 1
 
+    def _test_BuddyDemoApp_READ_As(self):
+
+        server_url = self.zope_url
+
+        # Request the @@contents.html at the root of Zope3
+        self.get("%s" %(server_url),
+                 description="View the buddy folders")
+
+        # Find randomly one of the buddy folders created and try to
+        # view it
+        links = self.listHref(pattern='buddy_folder_')
+        if links:
+            index = random.randrange(len(links)-1)
+            url = links[index]
+            self.get("%s/%s" %(server_url, url),
+                     description="View a buddy folder")
+
     def test_BuddyDemoApp_READ_As_Manager(self):
         """Tests read only tests 
         """
         self.setBasicAuth(self.admin_id, self.admin_pwd)
-
-        # Display the contents of each buddy folders
-        for id_ in self._buddies_folder_ids:
-            self.get("%s/%s" %(server_url, id_),
-                     description="View a buddy folder")
+        self._test_BuddyDemoApp_READ_As()
 
     def test_BuddyDemoApp_READ_As_Member(self):
         """Tests read only tests 
         """
         self.setBasicAuth(self.member_id, self.member_pwd)
-
-        # Display the contents of each buddy folders
-        for id_ in self._buddies_folder_ids:
-            self.get("%s/%s" %(server_url, id_),
-                     description="View a buddy folder")
+        self._test_BuddyDemoApp_READ_As()
 
     def test_ZZZ_RemoveBuddyFolders(self):
         """Remove all the created buddy folders
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to