changeset 4766:c198eff7b345

Groups 2009: Docstrings for the groups module tests, typos for tests
author Dmitrijs Milajevs <dimazest@gmail.com>
date Tue, 26 May 2009 13:24:44 +0200
parents 3ffc3eb7f265
children 3b34bbd60dca
files MoinMoin/groups/_test/test_backend_manager.py MoinMoin/groups/_test/test_group_manager.py
diffstat 2 files changed, 45 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/groups/_test/test_backend_manager.py	Tue May 26 12:58:50 2009 +0200
+++ b/MoinMoin/groups/_test/test_backend_manager.py	Tue May 26 13:24:44 2009 +0200
@@ -11,9 +11,10 @@
 
 from MoinMoin.groups import BackendManager
 
-
-class TestBackendManager(object):
-
+class TestBackendManagerAPI(object):
+    """
+    This tastcase test Backend manager API
+    """
     def setup_method(self, method):
         self.admin_group = frozenset([u'Admin', u'JohnDoe'])
         self.editor_group = frozenset([u'MainEditor', u'JohnDoe'])
@@ -26,18 +27,30 @@
         self.group_backend = BackendManager(backend=groups)
 
     def test_getitem(self):
+        """
+        Test of the __getitem__ API method. It should return a group
+        object by the group name.
+        """
         assert self.admin_group == self.group_backend[u'AdminGroup']
         assert self.fruit_group == self.group_backend[u'FruitGroup']
 
         raises(KeyError, lambda: self.group_backend[u'not existing group'])
 
     def test_contains(self):
+        """
+        Test of the __contains__ API method. It checks if a group is
+        avaliable via this backend. Check is done by group's name.
+        """
         assert u'AdminGroup' in self.group_backend
         assert u'FruitGroup' in self.group_backend
 
         assert u'not existing group' not in self.group_backend
 
     def  test_membergroups(self):
+        """
+        Test of membergroups API method. It lists all groups where
+        member is a member of. It should  return a list of group names.
+        """
         apple_groups = self.group_backend.membergroups(u'Apple')
         assert 1 == len(apple_groups)
         assert u'FruitGroup' in apple_groups
--- a/MoinMoin/groups/_test/test_group_manager.py	Tue May 26 12:58:50 2009 +0200
+++ b/MoinMoin/groups/_test/test_group_manager.py	Tue May 26 13:24:44 2009 +0200
@@ -12,10 +12,12 @@
 from MoinMoin.groups import BackendManager, GroupManager
 
 
-class TestGroupManager(object):
+class TestGroupManagerAPI(object):
+    """
+    Performs test of the API of GroupManager.
+    """
 
     def setup_method(self, method):
-
         self.admin_group = frozenset([u'Admin', u'JohnDoe'])
         self.editor_group = frozenset([u'MainEditor', u'JohnDoe'])
         self.fruit_group = frozenset([u'Apple', u'Banana', u'Cherry'])
@@ -32,7 +34,7 @@
 
         second_backend = BackendManager({u'UserGroup': self.user_group,
                                          u'CityGroup': self.city_group,
-                                         # Here group name clash accours.
+                                         # Here group name clash occurs.
                                          # AdminGroup is defined in both
                                          # first_backend and second_backend.
                                          u'AdminGroup': self.second_admin_group})
@@ -41,10 +43,19 @@
                                                       second_backend])
 
     def test_getitem(self):
+        """
+        Tests __getitem__ API method. It should return a group by its name.
+        """
         assert self.fruit_group == self.group_manager[u'FruitGroup']
         raises(KeyError, lambda: self.group_manager[u'not existing group'])
 
     def test_clashed_getitem(self):
+        """
+        This test check situation when groups with a same name are
+        defined in several backends. In this case, the only one
+        backend must be taken in consideration, that backend which is
+        defined first in the backends list.
+        """
         admin_group = self.group_manager[u'AdminGroup']
 
         assert self.admin_group == admin_group
@@ -54,18 +65,31 @@
         # in first backend
         assert u'TheHacker' not in admin_group
 
-    def test_itar(self):
+    def test_iter(self):
+        """
+        Tests __iter__ API method. It should iterate over all groups
+        available via backends. It should avoid group name clashes.
+        """
         all_group_names = [group_name for group_name in self.group_manager]
 
         assert 5 == len(all_group_names)
-        # There are no dublicates
+        # There are no duplicates
         assert len(set(all_group_names)) == len(all_group_names)
 
     def test_contains(self):
+        """
+        Tests __contains__ API method. It should check if a group
+        called group_name is available via some backend.
+        """
         assert u'UserGroup' in self.group_manager
         assert u'not existing group' not in self.group_manager
 
     def test_membergroups(self):
+        """
+        Tests membergroups API method. It should lists all groups
+        where member is a member of. It should return a list of group
+        names.
+        """
         apple_groups = self.group_manager.membergroups(u'Apple')
         assert 1 == len(apple_groups)
         assert u'FruitGroup' in apple_groups