예제 #1
0
def make_test_env(module):
    global SESSION_COUNT
    try:
        shutil.rmtree('test_instance')
    except:
        pass

    os.system('mysqladmin -f drop tiddlyspacetest create tiddlyspacetest')
    if SESSION_COUNT > 1:
        del sys.modules['tiddlywebplugins.tiddlyspace.store']
        del sys.modules['tiddlywebplugins.mysql2']
        del sys.modules['tiddlywebplugins.sqlalchemy2']
        import tiddlywebplugins.tiddlyspace.store
        import tiddlywebplugins.mysql2
        import tiddlywebplugins.sqlalchemy2
        clear_hooks(HOOKS)
    SESSION_COUNT += 1
    db_config = init_config['server_store'][1]['db_config']
    db_config = db_config.replace('///tiddlyspace?', '///tiddlyspacetest?')
    init_config['server_store'][1]['db_config'] = db_config
    init_config['log_level'] = 'DEBUG'

    if sys.path[0] != os.getcwd():
        sys.path.insert(0, os.getcwd())
    spawn('test_instance', init_config, instance_module)
    os.symlink('../tiddlywebplugins/templates', 'templates')

    from tiddlyweb.web import serve
    module.store = get_store(config)

    app = serve.load_app()

    def app_fn():
        return app
    module.app_fn = app_fn
예제 #2
0
    def test_create_tiddlywebwiki_instance(self):
        spawn(instance_dir, config, instance_module)

        contents = _get_file_contents('../%s/tiddlywebconfig.py' % instance_dir)

        assert "'system_plugins': ['tiddlywebwiki']" in contents
        assert "'twanager_plugins': ['tiddlywebwiki']" in contents
예제 #3
0
    def test_create_bag_policies(self):
        spawn(instance_dir, config, instance_module)

        bag = Bag('system')
        system_policy = self.store.get(bag).policy
        bag = Bag('common')
        common_policy = self.store.get(bag).policy

        assert system_policy.read == []
        assert system_policy.write == ['R:ADMIN']
        assert system_policy.create == ['R:ADMIN']
        assert system_policy.manage == ['R:ADMIN']
        assert system_policy.accept == ['R:ADMIN']
        assert system_policy.delete == ['R:ADMIN']

        assert common_policy.read == []
        assert common_policy.write == []
        assert common_policy.create == []
        assert common_policy.manage == ['R:ADMIN']
        assert common_policy.accept == []
        assert common_policy.delete == []
예제 #4
0
def make_test_env(module):
    global SESSION_COUNT
    try:
        shutil.rmtree('test_instance')
    except:
        pass

    os.system('mysqladmin -f drop tiddlyspacetest create tiddlyspacetest')
    if SESSION_COUNT > 1:
        del sys.modules['tiddlywebplugins.tiddlyspace.store']
        del sys.modules['tiddlywebplugins.mysql2']
        del sys.modules['tiddlywebplugins.sqlalchemy2']
        import tiddlywebplugins.tiddlyspace.store
        import tiddlywebplugins.mysql2
        import tiddlywebplugins.sqlalchemy2
        clear_hooks(HOOKS)
    SESSION_COUNT += 1
    db_config = init_config['server_store'][1]['db_config']
    db_config = db_config.replace('///tiddlyspace?', '///tiddlyspacetest?')
    init_config['server_store'][1]['db_config'] = db_config
    init_config['log_level'] = 'DEBUG'

    if sys.path[0] != os.getcwd():
        sys.path.insert(0, os.getcwd())
    spawn('test_instance', init_config, instance_module)
    os.symlink('../tiddlywebplugins/templates', 'templates')

    from tiddlyweb.web import serve
    module.store = get_store(config)

    app = serve.load_app()

    def app_fn():
        return app

    module.app_fn = app_fn