# Path: rpaas/tasks.py
# def setup_redis_url():
# def initialize_celery():
#     def __init__(self, config=None):
#     def ensure_ready(self, name):
#     def remove(self, name):
#     def create(self, name):
#     def update(self, name, task_id):
#     def init_config(self, config=None):
#     def _get_conf(self, key, default=config.undefined):
#     def _add_host(self, name, lb=None):
#     def _delete_host(self, name, host, lb=None):
#     def run(self, config, name):
#     def _should_destroy_lb(self):
#     def run(self, config, name):
#     def run(self, config, name, quantity):
#     def run(self, config):
#     def _restore_machine(self, task, config, healthcheck_timeout):
#     def _failure_instances(self, retry_failure_query, retry_failure_delay):
#     def run(self, config):
#     def _check_machine_exists(self, address):
#     def run(self, config, name, plugin, csr, key, domain):
#     def run(self, config, name, plugin, domain):
#     def run(self, config):
#     def renew(self, cert, config):
#     def run(self, config):
#     def rotate_session_ticket(self, hosts):
#     def add_session_ticket(self, host, session_ticket):
# class NotReadyError(Exception):
# class TaskNotFoundError(Exception):
# class TaskManager(object):
# class BaseManagerTask(Task):
# class NewInstanceTask(BaseManagerTask):
# class RemoveInstanceTask(BaseManagerTask):
# class ScaleInstanceTask(BaseManagerTask):
# class RestoreMachineTask(BaseManagerTask):
# class CheckMachineTask(BaseManagerTask):
# class DownloadCertTask(BaseManagerTask):
# class RevokeCertTask(BaseManagerTask):
# class RenewCertsTask(BaseManagerTask):
# class SessionResumptionTask(BaseManagerTask):


import unittest
import os
import redis
import time
from rpaas import tasks
        os.environ[env_var] = env_value
        app = tasks.initialize_celery()
        ch = app.broker_connection().channel()
        ch.client.set('mykey', env_var)
        self.assertEqual(ch.client.get('mykey'), env_var)
        self.assertEqual(ch.client.info()['tcp_port'], redis_port)
        self.assertEqual(app.backend.client.info()['tcp_port'], redis_port)

    def test_default_redis_connection(self):
        app = tasks.initialize_celery()
        ch = app.broker_connection().channel()
        ch.client.set('mykey', '1')
        self.assertEqual(ch.client.get('mykey'), '1')
        self.assertEqual(ch.client.info()['tcp_port'], 6379)
        self.assertEqual(app.backend.client.info()['tcp_port'], 6379)

    def test_sentinel_with_many_envs(self):
        self.with_env_var('RANDOM_VAR', 'random_value', 6379)
        self.setUp()
        sentinel_endpoint = 'sentinel://:mypass@127.0.0.1:51111,127.0.0.1:51112/service_name:mymaster'
        self.with_env_var('SENTINEL_ENDPOINT', sentinel_endpoint, self.master_port)
        self.setUp()
        dbaas_endpoint = sentinel_endpoint
        self.with_env_var('DBAAS_SENTINEL_ENDPOINT', dbaas_endpoint, self.master_port)
        self.setUp()
        redis_endpoint = 'redis://127.0.0.1:6379/0'
        self.with_env_var('REDIS_ENDPOINT', redis_endpoint, 6379)

    def test_simple_redis_string(self):
        os.environ['REDIS_ENDPOINT'] = "redis://:mypass@127.0.0.1:{}/0".format(self.master_port)

# Path: rpaas/tasks.py
# def setup_redis_url():
# def initialize_celery():
#     def __init__(self, config=None):
#     def ensure_ready(self, name):
#     def remove(self, name):
#     def create(self, name):
#     def update(self, name, task_id):
#     def init_config(self, config=None):
#     def _get_conf(self, key, default=config.undefined):
#     def _add_host(self, name, lb=None):
#     def _delete_host(self, name, host, lb=None):
#     def run(self, config, name):
#     def _should_destroy_lb(self):
#     def run(self, config, name):
#     def run(self, config, name, quantity):
#     def run(self, config):
#     def _restore_machine(self, task, config, healthcheck_timeout):
#     def _failure_instances(self, retry_failure_query, retry_failure_delay):
#     def run(self, config):
#     def _check_machine_exists(self, address):
#     def run(self, config, name, plugin, csr, key, domain):
#     def run(self, config, name, plugin, domain):
#     def run(self, config):
#     def renew(self, cert, config):
#     def run(self, config):
#     def rotate_session_ticket(self, hosts):
#     def add_session_ticket(self, host, session_ticket):
# class NotReadyError(Exception):
# class TaskNotFoundError(Exception):
# class TaskManager(object):
# class BaseManagerTask(Task):
# class NewInstanceTask(BaseManagerTask):
# class RemoveInstanceTask(BaseManagerTask):
# class ScaleInstanceTask(BaseManagerTask):
# class RestoreMachineTask(BaseManagerTask):
# class CheckMachineTask(BaseManagerTask):
# class DownloadCertTask(BaseManagerTask):
# class RevokeCertTask(BaseManagerTask):
# class RenewCertsTask(BaseManagerTask):
# class SessionResumptionTask(BaseManagerTask):


# Path: tests/test_tasks.py
import unittest
import os
import redis
import time
from rpaas import tasks

        os.environ[env_var] = env_value
        app = tasks.initialize_celery()
        ch = app.broker_connection().channel()
        ch.client.set('mykey', env_var)
        self.assertEqual(ch.client.get('mykey'), env_var)
        self.assertEqual(ch.client.info()['tcp_port'], redis_port)
        self.assertEqual(app.backend.client.info()['tcp_port'], redis_port)

    def test_default_redis_connection(self):
        app = tasks.initialize_celery()
        ch = app.broker_connection().channel()
        ch.client.set('mykey', '1')
        self.assertEqual(ch.client.get('mykey'), '1')
        self.assertEqual(ch.client.info()['tcp_port'], 6379)
        self.assertEqual(app.backend.client.info()['tcp_port'], 6379)

    def test_sentinel_with_many_envs(self):
        self.with_env_var('RANDOM_VAR', 'random_value', 6379)
        self.setUp()
        sentinel_endpoint = 'sentinel://:mypass@127.0.0.1:51111,127.0.0.1:51112/service_name:mymaster'
        self.with_env_var('SENTINEL_ENDPOINT', sentinel_endpoint, self.master_port)
        self.setUp()
        dbaas_endpoint = sentinel_endpoint
        self.with_env_var('DBAAS_SENTINEL_ENDPOINT', dbaas_endpoint, self.master_port)
        self.setUp()
        redis_endpoint = 'redis://127.0.0.1:6379/0'
        self.with_env_var('REDIS_ENDPOINT', redis_endpoint, 6379)

    def test_simple_redis_string(self):
        os.environ['REDIS_ENDPOINT'] = "redis://:mypass@127.0.0.1:{}/0".format(self.master_port)

        app = tasks.initialize_celery()