view MoinMoin/_tests/test_wikisync.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 48f3e2ab7365
children
line wrap: on
line source

# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - MoinMoin.wikisync tests

    @copyright: 2006 MoinMoin:AlexanderSchremmer
    @license: GNU GPL, see COPYING for details.
"""

import py

from MoinMoin.PageEditor import PageEditor
from MoinMoin.wikisync import TagStore, BOTH


class TestUnsafeSync(object):
    """ Tests various things related to syncing. Note that it is not possible
        to create pages without cluttering page revision currently, so we have to use
        the testwiki. """

    def setup_method(self, method):
        if not getattr(self.request.cfg, 'is_test_wiki', False):
            py.test.skip('This test needs to be run using the test wiki.')
        self.page = PageEditor(self.request, "FrontPage")

    def testBasicTagThings(self):
        tags = TagStore(self.page)
        assert not tags.get_all_tags()
        tags.add(remote_wiki="foo", remote_rev=1, current_rev=2, direction=BOTH, normalised_name="FrontPage")
        tags = TagStore(self.page) # reload
        dummy = repr(tags.get_all_tags()) # this should not raise
        assert tags.get_all_tags()[0].remote_rev == 1

    def teardown_method(self, method):
        tags = TagStore(self.page)
        tags.clear()

coverage_modules = ['MoinMoin.wikisync']