faust.livecheck.case
¶
LiveCheck - Test cases.
- class faust.livecheck.case.Case(*, app: _LiveCheck, name: str, probability: Optional[float] = None, warn_stalled_after: Optional[Union[timedelta, float, str]] = None, active: Optional[bool] = None, signals: Optional[Iterable[BaseSignal]] = None, test_expires: Optional[Union[timedelta, float, str]] = None, frequency: Optional[Union[timedelta, float, str]] = None, realtime_logs: Optional[bool] = None, max_history: Optional[int] = None, max_consecutive_failures: Optional[int] = None, url_timeout_total: Optional[float] = None, url_timeout_connect: Optional[float] = None, url_error_retries: Optional[int] = None, url_error_delay_min: Optional[float] = None, url_error_delay_backoff: Optional[float] = None, url_error_delay_max: Optional[float] = None, **kwargs: Any)[source]¶
LiveCheck test case.
- Runner¶
alias of
TestRunner
- last_test_received: Optional[float] = None¶
The warn_stalled_after timer uses this to keep track of either when a test was last received, or the last time the timer timed out.
- app: _LiveCheck¶
- warn_stalled_after: float = 1800.0¶
Timeout in seconds for when after we warn that nothing is processing.
- signals: Dict[str, BaseSignal]¶
- frequency: Optional[float] = None¶
How often we execute the test using fake data (define Case.make_fake_request()).
Set to None if production traffic is frequent enough to satisfy
warn_stalled_after
.
- realtime_logs = False¶
- max_history: int = 100¶
Max items to store in
latency_history
andruntime_history
.
- maybe_trigger(id: Optional[str] = None, *args: Any, **kwargs: Any) AsyncGenerator[Optional[TestExecution], None] [source]¶
Schedule test execution, or not, based on probability setting.
- Return type:
_GenericAlias
[_UnionGenericAlias
[TestExecution
,None
],None
]
- async trigger(id: Optional[str] = None, *args: Any, **kwargs: Any) TestExecution [source]¶
Schedule test execution ASAP.
- Return type:
- async run(*test_args: Any, **test_kwargs: Any) None [source]¶
Override this to define your test case.
- Return type:
None
- logger: logging.Logger = <Logger faust.livecheck.case (WARNING)>¶
- async resolve_signal(key: str, event: SignalEvent) None [source]¶
Mark test execution signal as resolved.
- Return type:
None
- log: CompositeLogger¶
- diag: DiagT¶
- async_exit_stack: AsyncExitStack¶
- exit_stack: ExitStack¶
- async execute(test: TestExecution) None [source]¶
Execute test using
TestRunner
.- Return type:
None
- async on_test_start(runner: TestRunner) None [source]¶
Call when a test starts executing.
- Return type:
None
- async on_test_skipped(runner: TestRunner) None [source]¶
Call when a test is skipped.
- Return type:
None
- async on_test_failed(runner: TestRunner, exc: BaseException) None [source]¶
Call when invariant in test execution fails.
- Return type:
None
- async on_test_error(runner: TestRunner, exc: BaseException) None [source]¶
Call when a test execution raises an exception.
- Return type:
None
- async on_test_timeout(runner: TestRunner, exc: BaseException) None [source]¶
Call when a test execution times out.
- Return type:
None
- async on_test_pass(runner: TestRunner) None [source]¶
Call when a test execution passes.
- Return type:
None
- async post_report(report: TestReport) None [source]¶
Publish test report.
- Return type:
None
- async on_suite_fail(exc: SuiteFailed, new_state: State = State.FAIL) None [source]¶
Call when the suite fails.
- Return type:
None
- property seconds_since_last_fail: Optional[float]¶
Return number of seconds since any test failed. :rtype:
_UnionGenericAlias
[float
,None
]
- async get_url(url: Union[str, URL], **kwargs: Any) Optional[bytes] [source]¶
Perform GET request using HTTP client.
- Return type:
_UnionGenericAlias
[bytes
,None
]
- async post_url(url: Union[str, URL], **kwargs: Any) Optional[bytes] [source]¶
Perform POST request using HTTP client.
- Return type:
_UnionGenericAlias
[bytes
,None
]
- async url_request(method: str, url: Union[str, URL], **kwargs: Any) Optional[bytes] [source]¶
Perform URL request using HTTP client.
- Return type:
_UnionGenericAlias
[bytes
,None
]
- property current_test: Optional[TestExecution]¶
Return the currently active test in this task (if any). :rtype:
_UnionGenericAlias
[TestExecution
,None
]
- property current_execution: Optional[TestRunner]¶
Return the currently executing
TestRunner
in this task. :rtype:_UnionGenericAlias
[TestRunner
,None
]