How to use the rele.discover function in rele

To help you get started, we’ve selected a few rele examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mercadona / rele / tests / test_discover.py View on Github external
def test_raises_when_incorrect_path(self):
        incorrect_path = "tests.foo"
        with pytest.raises(ModuleNotFoundError):
            discover.sub_modules(incorrect_path)
github mercadona / rele / tests / test_discover.py View on Github external
def test_returns_settings_and_paths_when_settings_found(self):
        discovered_settings, paths = discover.sub_modules("tests.settings")

        assert discovered_settings is settings
        assert discovered_settings.RELE == settings.RELE
        assert paths == ["tests.subs", "tests.more_subs.subs"]
github mercadona / rele / rele / __main__.py View on Github external
"current path. Auto-discovery will include all subs "
        "and settings modules. If no settings module is discovered, "
        "defaults will be used.",
    )
    run_parser.add_argument(
        "--settings",
        "-s",
        default=None,
        required=False,
        help="Settings file dot path. Ex. project.settings. "
        "If none is supplied, Relé will attempt to autodiscover in the root path.",
    )
    args = parser.parse_args()

    if args.command == "run":
        settings, module_paths = discover.sub_modules(args.settings)
        configuration = config.setup(settings.RELE if settings else None)
        subs = config.load_subscriptions_from_paths(
            module_paths, configuration.sub_prefix, configuration.filter_by
        )
        create_and_run(subs, configuration)