Esempio n. 1
0
 def test_str_to_bool(self):
     for s in ("false", "no", "0"):
         self.assertFalse(defaults.str_to_bool(s))
     for s in ("true", "yes", "1"):
         self.assertTrue(defaults.str_to_bool(s))
     with self.assertRaises(TypeError):
         defaults.str_to_bool("unsure")
Esempio n. 2
0
 def test_str_to_bool(self):
     for s in ("false", "no", "0"):
         self.assertFalse(defaults.str_to_bool(s))
     for s in ("true", "yes", "1"):
         self.assertTrue(defaults.str_to_bool(s))
     with self.assertRaises(TypeError):
         defaults.str_to_bool("unsure")
Esempio n. 3
0
                "django.contrib.contenttypes",
                "django.contrib.sessions",
                "django.contrib.admin",
                "django.contrib.admindocs",
                "djcelery")

DEFAULTS = {"ROOT_URLCONF": "djcelery.monproj.urls",
            "DATABASE_ENGINE": "sqlite3",
            "DATABASE_NAME": "djcelerymon.db",
            "DATABASES": {"default": {
                            "ENGINE": "django.db.backends.sqlite3",
                            "NAME": "djcelerymon.db"}},
            "BROKER_URL": "amqp://",
            "SITE_ID": 1,
            "INSTALLED_APPS": DEFAULT_APPS,
            "DEBUG": str_to_bool(os.environ.get("DJCELERYMON_DEBUG", "0"))}


def default_settings(name="__default_settings__"):
    c = type(name, (types.ModuleType, ), DEFAULTS)(name)
    c.__dict__.update({"__file__": __file__})
    sys.modules[name] = c
    return name


def configure():
    from celery import current_app
    from celery.loaders.default import DEFAULT_CONFIG_MODULE
    from django.conf import settings

    if not settings.configured:
Esempio n. 4
0
                "django.contrib.admindocs", "djcelery")

DEFAULTS = {
    "ROOT_URLCONF": "djcelery.monproj.urls",
    "DATABASE_ENGINE": "sqlite3",
    "DATABASE_NAME": "djcelerymon.db",
    "DATABASES": {
        "default": {
            "ENGINE": "django.db.backends.sqlite3",
            "NAME": "djcelerymon.db"
        }
    },
    "BROKER_URL": "amqp://",
    "SITE_ID": 1,
    "INSTALLED_APPS": DEFAULT_APPS,
    "DEBUG": str_to_bool(os.environ.get("DJCELERYMON_DEBUG", False))
}


def default_settings(name="__default_settings__"):
    c = type(name, (types.ModuleType, ), DEFAULTS)(name)
    c.__dict__.update({"__file__": __file__})
    sys.modules[name] = c
    return name


def configure():
    from celery import current_app
    from celery.loaders.default import DEFAULT_CONFIG_MODULE
    from django.conf import settings