changeset 5156:94fbaf908135

use DictMixin to make datastruct.BaseDict usable like a normal dict, add test
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 20 Sep 2009 00:00:12 +0200
parents b18473705235
children 9c67e4b79190
files MoinMoin/datastruct/backends/__init__.py MoinMoin/datastruct/backends/_tests/__init__.py
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/datastruct/backends/__init__.py	Sat Sep 19 21:33:48 2009 +0200
+++ b/MoinMoin/datastruct/backends/__init__.py	Sun Sep 20 00:00:12 2009 +0200
@@ -6,6 +6,8 @@
 @license: GPL, see COPYING for details
 """
 
+from UserDict import DictMixin
+
 
 class GroupDoesNotExistError(Exception):
     """
@@ -254,7 +256,7 @@
                                                              self.member_groups)
 
 
-class BaseDict(object):
+class BaseDict(object, DictMixin):
 
     def __init__(self, request, name, backend):
         """
@@ -273,6 +275,9 @@
     def __iter__(self):
         return self._dict.__iter__()
 
+    def keys(self):
+        return list(self)
+
     def __len__(self):
         return self._dict.__len__()
 
--- a/MoinMoin/datastruct/backends/_tests/__init__.py	Sat Sep 19 21:33:48 2009 +0200
+++ b/MoinMoin/datastruct/backends/_tests/__init__.py	Sun Sep 20 00:00:12 2009 +0200
@@ -165,6 +165,14 @@
 
         assert u'SomeNotExistingDict' not in dicts
 
+    def test_update(self):
+        dicts = self.request.dicts
+
+        d = {}
+        d.update(dicts['SomeTestDict'])
+
+        assert u'First' in d
+
     def test_get(self):
         dicts = self.request.dicts