Author: janguenot
Date: Tue Oct  4 18:40:08 2005
New Revision: 27928

Modified:
   z3lab/Zope3Benchs/trunk/Zope3.conf
   z3lab/Zope3Benchs/trunk/test_Zope3.py
Log:
Update functionnal tests and configuration

Modified: z3lab/Zope3Benchs/trunk/Zope3.conf
==============================================================================
--- z3lab/Zope3Benchs/trunk/Zope3.conf  (original)
+++ z3lab/Zope3Benchs/trunk/Zope3.conf  Tue Oct  4 18:40:08 2005
@@ -5,8 +5,8 @@
 # Main section
 #
 [main]
-title=Simple Zope3 tests
-description=Testing Zope3
+title=Testing Zope3
+description=Functional tests against Zope3 for benching purpose
 
 # the server url to test without the trailing '/'
 url=http://localhost:8080
@@ -15,12 +15,33 @@
 admin_id=admin
 admin_pwd=nimda
 
+member_id=member
+member_pwd=rebmem
+
 
 # ------------------------------------------------------------
 # Tests description and configuration
 #
-[test_anonymous]
-description=Check Anonymous access
+
+[test_EmptyInstance_As_Anonymous]
+description=Render default page as anonymous user
+
+[test_EmptyInstance_As_Manager]
+description=Render default page as Manager
+
+[test_EmptyInstance_As_Member]
+description=Render default page as Member
+
+[test_00_BuddyDemoApp_RW]
+description=Read / write tests on the buddy demo app
+nb_buddies_folder=5
+nb_buddies_per_folder=5
+
+[test_BuddyDemoApp_READ_As_Manager]
+description=Read tests on the buddy demo app as Manager
+
+[test_BuddyDemoApp_READ_As_Member]
+description=Read tests on the buddy demo app as Member
 
 # ------------------------------------------------------------
 # Monitoring configuration
@@ -72,7 +93,7 @@
 cycles =  1:2:3
 
 # duration = duration of a cycle in seconds
-duration = 30
+duration = 250
 
 # startup_delay = time to wait between starting-up threads in seconds
 startup_delay = 0.2

Modified: z3lab/Zope3Benchs/trunk/test_Zope3.py
==============================================================================
--- z3lab/Zope3Benchs/trunk/test_Zope3.py       (original)
+++ z3lab/Zope3Benchs/trunk/test_Zope3.py       Tue Oct  4 18:40:08 2005
@@ -19,10 +19,10 @@
 
 $Id$
 """
-
-from random import random
 import unittest
+from random import random
 from funkload.FunkLoadTestCase import FunkLoadTestCase
+from funkload.Lipsum import Lipsum
 
 class Zope3(FunkLoadTestCase):
     """Testing Zope3
@@ -33,37 +33,63 @@
     def setUp(self):
         """Setting up test.
         """
-
         self.logd("setUp.")
         self.zope_url = self.conf_get('main', 'url')
         self.admin_id = self.conf_get('main', 'admin_id')
         self.admin_pwd = self.conf_get('main', 'admin_pwd')
+        self.member_id = self.conf_get('main', 'member_id')
+        self.member_pwd = self.conf_get('main', 'member_pwd')
 
-    ##def test_EmptyInstance_As_Anonymous(self):
-    ##    """Test an empty instance as anonymous user
-    ##    """
-    ##
-    ##    server_url = self.zope_url
-    ##    self.get("%s/" % server_url)
-    ##
-    ##def test_EmptyInstance_As_Manager(self):
-    ##
-    ##    server_url = self.zope_url
-    ##
-    ##    self.setBasicAuth(self.admin_id, self.admin_pwd)
-    ##    self.get("%s/" % server_url)
+        # For cleaning up at the end
+        self._buddies_folder_ids = []
 
-    def test_BuddyDemoApp(self):
+    def test_EmptyInstance_As_Anonymous(self):
+        """Test an empty instance as anonymous user
 
+        This request the default Zope3 page
+        """
         server_url = self.zope_url
+        self.get("%s/" % server_url, description="Zope3 default page")
+
+    def test_EmptyInstance_As_Manager(self):
+        """Test an ampty instance as Manager
 
+        This request the default Zope3 page
+        """
+        server_url = self.zope_url
         self.setBasicAuth(self.admin_id, self.admin_pwd)
-        self.get("%s/" % server_url)
-        self.get("%s/@@+" % server_url)
+        self.get("%s/" % server_url, description="Zope3 default page")
 
-        j = 0
+    def test_EmptyInstance_As_Member(self):
+        """Test an ampty instance as Member
+
+        This request the default Zope3 page
+        """
+        server_url = self.zope_url
+        self.setBasicAuth(self.admin_id, self.admin_pwd)
+        self.get("%s/" % server_url, description="Zope3 default page")
+
+    def test_00_BuddyDemoApp_RW(self):
+        """Test the buddy demo application.
+
+        The buddy demo application is a simple application involving
+        containers and objects within the container
+        """
+        server_url = self.zope_url
+
+        nb_buddies_folder = self.conf_get(
+            'test_00_BuddyDemoApp_RW', 'nb_buddies_folder')
+        nb_buddies_per_folder = self.conf_get(
+            'test_00_BuddyDemoApp_RW', 'nb_buddies_per_folder')
 
-        while j < 5:
+        self.setBasicAuth(self.admin_id, self.admin_pwd)
+        self.get("%s/" % server_url, description="Zope3 default page")
+        self.get("%s/@@+" % server_url,
+                 description="Zope3 `add content page` "
+                             "at the root of the instance")
+
+        j = 0
+        while j < int(nb_buddies_folder):
 
             # Create the buddies folder
             buddies_folder_id = str(random())
@@ -72,16 +98,19 @@
                 ['id', buddies_folder_id],
                 ['add', 'Add'],
                 ]
-            self.post("%s/@@+/action.html" % server_url, params)
-            
+            self.post("%s/@@+/action.html" % server_url,
+                      params=params, description="Add a buddy")
+
             # Create 500 buddies
-            
-            self.get("%s/%s/@@contents.html" %(server_url, buddies_folder_id))
-            
+
+            self.get("%s/%s/@@contents.html" %(server_url, buddies_folder_id),
+                     description="View the Zope3 root content items")
+
             i = 0
-            while i < 10:
-                self.get("%s/%s/@@+" %(server_url, buddies_folder_id))
-            
+            while i < int(nb_buddies_per_folder):
+                self.get("%s/%s/@@+" %(server_url, buddies_folder_id),
+                         description="Buddy folder `add content`page")
+
                 # Create the buddies folder
                 # Step1 : Ask for the creation given an id
                 buddy_id = str(random())
@@ -90,8 +119,9 @@
                     ['id', buddy_id],
                     ['add', ' Add '],
                     ]
-                self.post("%s/@@+/action.html" % server_url, params)
-            
+                self.post("%s/@@+/action.html" % server_url, params,
+                          description="Request to add a buddy")
+
                 # Give informations and create the buddy
                 params = [
                     ['type_name', 'AddBuddy.html'],
@@ -104,17 +134,21 @@
                     ]
                 self.post("%s/%s/+/AddBuddy.html=%s" %(server_url,
                                                        buddies_folder_id,
-                                                       buddy_id), params)
-            
+                                                       buddy_id),
+                          params=params,
+                          description="Add a buddy")
+
                 # View the buddy
                 self.get("%s/%s/@@contents.html" % (server_url,
-                                                    buddies_folder_id))
+                                                    buddies_folder_id),
+                         description="View the buddies")
                 self.get("%s/%s/%s/@@edit.html" %(server_url,
                                                   buddies_folder_id,
-                                                  buddy_id))
-            
+                                                  buddy_id),
+                         description="Edit a buddy form")
+
                 # Edit back the buddy
-            
+
                 params = [
                     ['field.first', 'Julien'],
                     ['field.last', 'Anguenot'],
@@ -123,27 +157,58 @@
                     ['field.postal_code','33000'],
                     ['UPDATE_SUBMIT', 'Change'],
                     ]
-            
+
                 self.post("%s/%s/%s/@@edit.html" %(server_url,
                                                    buddies_folder_id,
-                                                   buddy_id), params)
+                                                   buddy_id),
+                          params=params,
+                          description="Edit a buddy")
                 i += 1
+
+            # Delete the buddy folder
+            self.get("%s/@@contents.html" % server_url,
+                     description="View the contents at the root of the Zope3 "
+                                 "instance")
+            # Add this idea to the list of folders to delete
+            self._buddies_folder_ids.append(buddies_folder_id)
+
             j += 1
-        
-        # Delete the buddy folder
-        self.get("%s/@@contents.html" % server_url)
 
-        params = [
-            ['container_delete_button', 'Delete'],
-            ['ids:list', [buddies_folder_id]],
-            ]
+    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")
+
+    def test_BuddyDemoApp_READ_As_Member(self):
+        """Tests read only tests 
+        """
+        self.setBasicAuth(self.member_id, self.member_pwd)
 
-        # XXX cleanup
-        ##self.post("%s/@@contents.html" % server_url, params)
+        # 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")
 
     def tearDown(self):
         """Setting down test.
+
+        Remove the buddy folders created during the test
         """
+        server_url = self.zope_url
+        self.setBasicAuth(self.admin_id, self.admin_pwd)
+        params = [
+            ['container_delete_button', 'Delete'],
+            ['ids:list', self._buddies_folder_ids],
+                ]
+        self.post("%s/@@contents.html" % server_url,
+                  params=params,
+                  description="Delete several buddy folders")
+        
         self.logd("tearDown.")
 
 if __name__ in ('main', '__main__'):
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to