register_mock_discovery#

rubin.repertoire.register_mock_discovery(respx_mock, results, base_url=None)#

Mock out the Repertoire discovery server.

This does not mock retrieval of InfluxDB connection information.

Parameters:
  • respx_mock (Router) – Mock router.

  • results (Discovery | dict[str, Any] | Path) – Mock results to return when HTTPX code requests service discovery. This can be a Discovery object, the equivalent as a dict (using the same syntax as parsed JSON), or a Path to a JSON file.

  • base_url (str | None, default: None) – Base URL at which to mock the Repertoire service. If this is not given, the environment variable REPERTOIRE_BASE_URL must be set before calling this function (usually via pytest’s monkeypatch.setenv) and will be used as the default.

Returns:

Parsed discovery results that will be returned from the mocked endpoint.

Return type:

Discovery

Raises:

RepertoireUrlError – Raised if REPERTOIRE_BASE_URL is not set in the environment and base_url is not provided.