This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ♻️ refactor(deps): require dependencies based on plugin config * 🐛 fix: tox config * ♻️ refactor(tox): append coverage in testenv:noextras * ♻️ refactor(tox): don't run coverage in parallel mode in testenv:noextras * 🐛 fix: full coverage * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ♻️ refactor: apply changes from review * 🐛 fix: linters * ♻️ refactor: full coverage * ♻️ refactor: update pytest plugin fixtures * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ✅ test: fix tests * ♻️ refactor: add sqlalchemy to optional dependencies * ♻️ refactor: silent flake8 * ✅ test(tox): make noextras passing the full test suite * ♻️ refactor: silent pyright * 📝 docs: update readme * 📝 docs: update readme * refactor: requirements/tox/etc * style: rollback style changes The bigger the PR, the better it is if we keep the changes to bare minimum. * refactor: run pytest plugin tests in sub-process. This prevents the need to reload any modules, albeit it is a bit slower. * refactor: no top level conditional imports. * refactor: makes lifespan check imports and logic conditional * refactor: no implicit imports of modules with optional functionality * refactor: move any worker related stuff out of service module * refactor: default_factory and validator for dependency-based gates Default values for `PluginConfig.do_cache` et al. are based on the `IS_XXX_INSTALLED` constants. We use `default_factory` so we can patch the module values in tests. Use `@validator` to test for missing dependency when gates are explicitly set. * refactor: remove more module scoped conditional imports. Import from within the test/fixture where appropriate. * refactor: organise tests according to dependencies (#257) * refactor: organise tests according to dependencies - organises tests according to their dependencies. - removes unnecessary autouse fixtures - removes gated imports at the module level - uses `--ignore` to exclude redis/sqlalchemy/sentry tests from no-extras tests * refactor: use `test_ignore_glob` pytest global This lets us skip test collection for a whole sub-package of tests if a dependency is unavailable. * refactor: log tests can run without sqlalchemy. This was only necessary due to the dependency on `tests.utils.controllers` in the `http_scope` fixture, which has now been removed. * refactor: don't need to skipif saq log tests As the log tests depend on `job` fixture which will automatically skip if SAQ not available. * refactor: remaining fixtures/tests requiring sqlalchemy moved into sqlalchemy directory. * refactor: continue splitting tests up by required dependency. Health checks are up. * refactor: add method for setting lifecycle handlers. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Peter Schutt <[email protected]>
- Loading branch information
1 parent
10a49c8
commit efe26d6
Showing
53 changed files
with
1,166 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-r requirements.dev.txt | ||
|
||
sentry-sdk >= "1.13.0" | ||
hiredis | ||
redis | ||
saq >= "0.9.1" | ||
sqlalchemy == 2.0.0rc2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,50 @@ | ||
"""Application constants.""" | ||
from __future__ import annotations | ||
|
||
from importlib import import_module | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from starlite_saqlalchemy.settings import app | ||
from starlite_saqlalchemy.utils import case_insensitive_string_compare | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import MutableMapping | ||
|
||
from starlite_saqlalchemy.service import Service | ||
|
||
|
||
IS_TEST_ENVIRONMENT = case_insensitive_string_compare(app.ENVIRONMENT, app.TEST_ENVIRONMENT_NAME) | ||
"""Flag indicating if the application is running in a test environment.""" | ||
|
||
IS_LOCAL_ENVIRONMENT = case_insensitive_string_compare(app.ENVIRONMENT, app.LOCAL_ENVIRONMENT_NAME) | ||
"""Flag indicating if application is running in local development mode.""" | ||
|
||
IS_REDIS_INSTALLED = True | ||
"""Flag indicating if redis module is installed.""" | ||
|
||
IS_SAQ_INSTALLED = True | ||
"""Flag indicating if saq module is installed.""" | ||
|
||
IS_SENTRY_SDK_INSTALLED = True | ||
"""Flag indicating if sentry_sdk module is installed.""" | ||
|
||
IS_SQLALCHEMY_INSTALLED = True | ||
"""Flag indicating if sqlalchemy module is installed.""" | ||
|
||
|
||
for package in ("redis", "saq", "sentry_sdk", "sqlalchemy"): | ||
try: | ||
import_module(package) | ||
except ModuleNotFoundError: | ||
match package: | ||
case "redis": | ||
IS_REDIS_INSTALLED = False | ||
case "saq": | ||
IS_SAQ_INSTALLED = False | ||
case "sentry_sdk": | ||
IS_SENTRY_SDK_INSTALLED = False | ||
case "sqlalchemy": # pragma: no cover | ||
IS_SQLALCHEMY_INSTALLED = False | ||
|
||
SERVICE_OBJECT_IDENTITY_MAP: MutableMapping[str, type[Service[Any]]] = {} | ||
"""Used by the worker to lookup methods for service object callbacks.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.