nat.test.utils#
Functions#
|
|
|
Locate the example src directory for an example's config class. |
|
Locate the example directory for an example's config class. |
|
Locate the example config file for an example's config class, assumes the example contains a 'configs' directory |
|
Test specific wrapper for |
|
Execute a workflow using |
|
Build a NAT client for testing purposes. |
|
Validate the contents of the workflow output file. |
Module Contents#
- locate_repo_root() pathlib.Path#
- locate_example_src_dir(example_config_class: type) pathlib.Path#
Locate the example src directory for an example’s config class.
- locate_example_dir(example_config_class: type) pathlib.Path#
Locate the example directory for an example’s config class.
- locate_example_config( ) pathlib.Path#
Locate the example config file for an example’s config class, assumes the example contains a ‘configs’ directory
- async run_workflow(
- *,
- config: Config | None = None,
- config_file: StrPath | None = None,
- question: str,
- expected_answer: str | None = None,
- assert_expected_answer: bool = True,
- \*\*kwargs,
Test specific wrapper for
nat.utils.run_workflowto run a workflow with a question and validate the expected answer. This variant always sets the result type tostr.
- async serve_workflow(
- *,
- config_path: pathlib.Path,
- question: str,
- expected_answer: str | None = None,
- assert_expected_answer: bool = True,
- port: int = 8000,
- pipeline_timeout: int = 60,
- request_timeout: int = 30,
Execute a workflow using
nat serve, and issue a POST request to the/generateendpoint with the given question.Intended to be analogous to
run_workflowbut for the REST API serving mode.
- async build_nat_client(
- config: nat.data_models.config.Config,
- worker_class: type[FastApiFrontEndPluginWorker] | None = None,
Build a NAT client for testing purposes.
Creates a test client with an ASGI transport for the specified configuration. The client is backed by a FastAPI application built from the provided worker class.
- Args:
config: The NAT configuration to use for building the client. worker_class: Optional worker class to use. Defaults to FastApiFrontEndPluginWorker.
- Yields:
An AsyncClient instance configured for testing.
- validate_workflow_output(workflow_output_file: pathlib.Path) None#
Validate the contents of the workflow output file. WIP: output format should be published as a schema and this validation should be done against that schema.