changeset 4827:fd6183cde452

Groups2009: groups.backends.BaseBackend now has get method, which works similar to dict.get().
author Dmitrijs Milajevs <dimazest@gmail.com>
date Sat, 27 Jun 2009 13:06:12 +0200
parents 9bee7b3e9235
children 0f86a6c578e3
files MoinMoin/groups/backends/__init__.py MoinMoin/groups/backends/_tests/__init__.py
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/groups/backends/__init__.py	Sat Jun 27 11:21:04 2009 +0200
+++ b/MoinMoin/groups/backends/__init__.py	Sat Jun 27 13:06:12 2009 +0200
@@ -156,3 +156,9 @@
             except GroupDoesNotExistError:
                 pass
 
+    def get(self, key, default=None):
+        if key in self:
+            return self[key]
+        else:
+            return default
+
--- a/MoinMoin/groups/backends/_tests/__init__.py	Sat Jun 27 11:21:04 2009 +0200
+++ b/MoinMoin/groups/backends/_tests/__init__.py	Sat Jun 27 13:06:12 2009 +0200
@@ -64,6 +64,13 @@
             for member in members:
                 assert member in returned_members
 
+    def test_get(self):
+        groups = self.request.groups
+
+        assert groups.get(u'AdminGroup')
+        assert u'NotExistingGroup' not in groups
+        assert groups.get(u'NotExistingGroup') is None
+
     def test_groups_with_member(self):
         groups = self.request.groups
 
@@ -130,5 +137,3 @@
 
         assert not acl.may(request, u"Someone", "write")
 
-coverage_modules = ['MoinMoin.groups.backends.config_group']
-