Runner API¶
The Python-side functions and data classes for talking to a viur-testing-armed server. Used by hosts that drive their own runner (a custom smoke harness, an internal CI tool, …).
The canonical Playwright e2e wiring lives in the npm companion
package @spltz/viur-testing
and is driven by createGlobalSetup() — the
primitives below are the same handshake, exposed for Python
callers that want to reuse it.
require_test_mode¶
require_test_mode
¶
require_test_mode(base_url: str, *, expected_database: str = DEFAULT_DATABASE, expected_namespace: str | None | Any = _UNSET, expected_project_id: str | None = None, timeout: float = 5.0, _opener: Callable[[Request, float], Any] | None = None) -> ServerStatus
Block until the running server confirms it is in test mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Origin of the server under test,
e.g. |
required |
expected_database
|
str
|
Database name we expect the server to be on.
Default |
DEFAULT_DATABASE
|
expected_namespace
|
str | None | Any
|
When supplied, the server's |
_UNSET
|
expected_project_id
|
str | None
|
If set, the server's |
None
|
timeout
|
float
|
HTTP timeout in seconds. |
5.0
|
_opener
|
Callable[[Request, float], Any] | None
|
Injection seam for tests. |
None
|
Returns:
| Type | Description |
|---|---|
ServerStatus
|
A :class: |
Raises:
| Type | Description |
|---|---|
TestModePreflightError
|
if any check fails. The caller must treat this as a hard stop and not run any test. |
Source code in src/viur/testing/runner.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
finish¶
finish
¶
finish(base_url: str, token: str | None = None, *, timeout: float = 5.0, _opener: Callable[[Request, float], Any] | None = None) -> dict
End the session: tell the server to delete the token entity.
/_test/config/finish is a bootstrap endpoint that deletes the
singleton token entity, so it needs no credential of its own — the
token argument is accepted for call-site compatibility but ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Origin of the server under test. |
required |
token
|
str | None
|
Ignored (kept for backwards compatibility). |
None
|
timeout
|
float
|
HTTP timeout in seconds. |
5.0
|
_opener
|
Callable[[Request, float], Any] | None
|
Injection seam for tests. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The parsed JSON response
( |
Raises:
| Type | Description |
|---|---|
TestModePreflightError
|
on transport errors or non-2xx responses. |
Source code in src/viur/testing/runner.py
ServerStatus¶
ServerStatus
dataclass
¶
Validated server-side snapshot returned by /_test/config/status.