comparison MoinMoin/_tests/test_user.py @ 6028:1893da1d5213

userid lookup caches: use 1 on-disk cache file, update cache rather than rebuild Before this, we maintained one cache file per attribute (e.g. name2id, openid2id, ...) - the related code did multiple passes over all user profiles to rebuild these cache files. Now doing a one-pass rebuild, writing all attribute -> userid mappings into one on-disk cache file called "lookup". Additionally to "name" and "openids", support fast lookup for "email" and "jid" also. On profile save, we use to just kill the cache and let it rebuild. Now the cache is read, updated and written back (which is much less expensive for wikis with more than a few users). Did some refactoring also, reducing duplication, breaking down the code into smaller functions / methods.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 12 Feb 2014 18:22:10 +0100
parents 05a6897ee496
children
comparison
equal deleted inserted replaced
6027:8618232296b5 6028:1893da1d5213
76 # Restore original user 76 # Restore original user
77 self.request.cookies = self.saved_cookie 77 self.request.cookies = self.saved_cookie
78 self.request.user = self.saved_user 78 self.request.user = self.saved_user
79 79
80 # Remove user lookup caches, or next test will fail 80 # Remove user lookup caches, or next test will fail
81 user.clearUserIdLookupCaches(self.request) 81 user.clearLookupCaches(self.request)
82 82
83 def testAsciiPassword(self): 83 def testAsciiPassword(self):
84 """ user: login with ascii password """ 84 """ user: login with ascii password """
85 # Create test user 85 # Create test user
86 name = u'__Non Existent User Name__' 86 name = u'__Non Existent User Name__'
239 theUser = user.User(self.request, name=name, password=password) 239 theUser = user.User(self.request, name=name, password=password)
240 theUser.subscribe(pagename) 240 theUser.subscribe(pagename)
241 assert not theUser.isSubscribedTo([testPagename]) # list(!) of pages to check 241 assert not theUser.isSubscribedTo([testPagename]) # list(!) of pages to check
242 242
243 def testRenameUser(self): 243 def testRenameUser(self):
244 """ create user and then rename user and check 244 """ create user and then rename user and check whether
245 if the old username is removed from the cache name2id 245 the old username is removed (and the lookup cache behaves well)
246 """ 246 """
247 # Create test user 247 # Create test user
248 name = u'__Some Name__' 248 name = u'__Some Name__'
249 password = name 249 password = name
250 self.createUser(name, password) 250 self.createUser(name, password)