Add uninstalled, functional-layer, and request-builder fixtures#43
Merged
Add uninstalled, functional-layer, and request-builder fixtures#43
Conversation
Adds an `uninstalled` fixture that reads a user-provided `package_name` fixture and calls `installer.uninstall_product`. Removes the per-project boilerplate that downstream codebases duplicate in their canonical add-on uninstall smoke test. Closes #38
Adds `functional_app`, `functional_portal`, and `functional_http_request` as functional-layer counterparts to the existing integration-layer fixtures. `functional_portal` honors `@pytest.mark.portal`, matching the behavior of `portal`. This eliminates the most common reason downstream codebases override pytest-plone fixtures — aliasing `functional["portal"]` as `portal`. Closes #39
Introduces `request_factory`, `manager_request`, and `anon_request`, replacing the 5+ near-identical session fixtures that downstream codebases reimplement. `request_factory` returns a built-in `RelativeSession` (a thin `requests.Session` subclass) bound to the functional portal. Supported modes: `role="Manager"`, `role="Anonymous"` (default), or explicit `basic_auth=(user, password)`. The `++api++` suffix is added by default. The standalone `RelativeSession` avoids pulling in `plone.restapi[test]`'s fragile import chain (`plone.app.iterate`, `collective.MockMailHost`) while keeping the same calling convention downstream code already expects. Closes #40
CI runs `uvx mypy src` in an isolated environment that does not honor the project's `ignore_missing_imports=true` setting in pyproject.toml. Add an inline type: ignore on the `requests` import rather than broadening CI or adding `types-requests` just for a single import.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ships three high-signal fixture additions that eliminate the most common sources of boilerplate duplication across downstream Plone add-ons:
uninstalled— reads a user-providedpackage_namefixture and callsinstaller.uninstall_product. Removes the canonical copy-pasted autouse fixture used in add-on uninstall smoke tests.functional_app/functional_portal/functional_http_request— functional-layer counterparts toapp/portal/http_request.functional_portalhonors@pytest.mark.portalfor profiles, content, and roles.request_factory/manager_request/anon_request— builder + convenience fixtures returning aRelativeSessionagainst the functional portal. Supportsrole="Manager",role="Anonymous", or explicitbasic_auth=(user, password), with the++api++traverser enabled by default.Notes
RelativeSessionclass infixtures/requests.pyis a standalone minimal equivalent ofplone.restapi.testing.RelativeSession, chosen to avoid pulling inplone.restapi[test]'s fragile import chain (plone.app.iterate,collective.MockMailHost) as a hard pytest-plone dependency. Same calling convention downstream already expects.requestsis now an explicit runtime dependency (previously only transitive viaProducts.CMFPlone).Test plan
test_uninstalled.py,test_functional_layer.py,test_request_factory.pyfunctional_portalmarker behavior covered (roles, content, no-marker)request_factory: default/Manager/api=False/basic_auth/unknown-role/Accept headerRelativeSessionrelative-URL resolution and absolute-URL passthroughuv run pytest)ruff check+ruff formatcleanCloses #38
Closes #39
Closes #40