Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /hu55ain3laa_fastauth /tests /test_deprecations.py
| """The superseded method names must keep working until 1.0. | |
| Each old name should warn once, point at the caller, and return a dependency | |
| that behaves exactly like its replacement. | |
| """ | |
| import pytest | |
| from sqlmodel import create_engine | |
| from fastauth import FastAuth | |
| def auth(): | |
| engine = create_engine( | |
| "sqlite://", connect_args={"check_same_thread": False} | |
| ) | |
| return FastAuth(secret_key="a" * 32, engine=engine) | |
| def test_deprecated_names_warn_and_still_work(auth, call, replacement): | |
| with pytest.warns(DeprecationWarning) as record: | |
| dependency = call(auth) | |
| assert callable(dependency) | |
| message = str(record[0].message) | |
| assert "deprecated" in message | |
| assert replacement in message | |
| assert "1.0" in message | |
| def test_role_aliases_accept_the_same_arguments(auth): | |
| """auth.roles takes varargs or a list; the old name took a list only.""" | |
| with pytest.warns(DeprecationWarning): | |
| from_old = auth.require_roles(["admin", "premium"]) | |
| from_varargs = auth.roles("admin", "premium") | |
| from_list = auth.roles(["admin", "premium"]) | |
| assert all(callable(d) for d in (from_old, from_varargs, from_list)) | |
| def test_token_url_is_absolute_by_default(auth): | |
| """Swagger's Authorize button breaks on a relative tokenUrl under a prefix.""" | |
| assert auth.token_url == "/token" | |
| assert auth.oauth2_scheme.model.flows.password.tokenUrl == "/token" | |
| def test_token_url_missing_slash_is_normalised(): | |
| engine = create_engine("sqlite://", connect_args={"check_same_thread": False}) | |
| instance = FastAuth(secret_key="a" * 32, engine=engine, token_url="token") | |
| assert instance.token_url == "/token" | |
Xet Storage Details
- Size:
- 2.05 kB
- Xet hash:
- aca86e038428ff9e892f4c42eeeff8384127d2174c16739e8d129404f7fadd89
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.