def setUp(self):
     sentinel = Sentinel(app=FakeApp())
     self.connection = sentinel.master
     self.connection.flushall()
     self.guard = ContributionsGuard(self.connection)
     self.anon_user = {'user_id': None, 'user_ip': '127.0.0.1'}
     self.auth_user = {'user_id': 33, 'user_ip': None}
     self.task = Task(id=22)
示例#2
0
    * csrf: for CSRF protection
    * newsletter: for subscribing users to Mailchimp newsletter

"""
__all__ = [
    'sentinel', 'db', 'signer', 'mail', 'login_manager', 'facebook', 'twitter',
    'google', 'misaka', 'babel', 'uploader', 'debug_toolbar', 'csrf',
    'timeouts', 'ratelimits', 'user_repo', 'project_repo', 'task_repo',
    'blog_repo', 'auditlog_repo', 'newsletter', 'importer', 'flickr',
    'plugin_manager'
]

# CACHE
from pybossa.sentinel import Sentinel

sentinel = Sentinel()

# DB
from flask.ext.sqlalchemy import SQLAlchemy

db = SQLAlchemy()
db.slave_session = db.session

# Repositories
user_repo = None
project_repo = None
blog_repo = None
task_repo = None
auditlog_repo = None

# Signer
示例#3
0
        pwd = getattr(settings_test, 'REDIS_PWD', None)
        if all(
                hasattr(settings_test, attr) for attr in
            ['REDIS_MASTER_DNS', 'REDIS_SLAVE_DNS', 'REDIS_PORT']):
            self.config = dict(REDIS_MASTER_DNS=settings_test.REDIS_MASTER_DNS,
                               REDIS_SLAVE_DNS=settings_test.REDIS_SLAVE_DNS,
                               REDIS_PORT=settings_test.REDIS_PORT,
                               REDIS_PWD=pwd)
        else:
            self.config = {
                'REDIS_SENTINEL': settings_test.REDIS_SENTINEL,
                'REDIS_PWD': pwd
            }


test_sentinel = Sentinel(app=FakeApp())


@patch('pybossa.cache.sentinel', new=test_sentinel)
class TestCacheMemoizeFunctions(object):
    @classmethod
    def setup_class(cls):
        # Enable the cache for tests within this class
        import os
        cls.cache = None
        if os.environ.get('PYBOSSA_REDIS_CACHE_DISABLED'):
            cls.cache = os.environ.get('PYBOSSA_REDIS_CACHE_DISABLED')
            del os.environ['PYBOSSA_REDIS_CACHE_DISABLED']

    @classmethod
    def teardown_class(cls):