datalad_next.tests.fixtures

Collection of fixtures for facilitation test implementations

datalad_next.tests.fixtures.check_gitconfig_global()[source]

No test must modify a user's global Git config.

If such modifications are needed, a custom configuration setup limited to the scope of the test requiring it must be arranged.

datalad_next.tests.fixtures.check_plaintext_keyring()[source]

No test must modify a user's keyring.

If such modifications are needed, a custom keyring setup limited to the scope of the test requiring it must be arranged. The tmp_keyring fixture can be employed in such cases.

datalad_next.tests.fixtures.credman(datalad_cfg, tmp_keyring)[source]

Provides a temporary credential manager

It comes with a temporary global datalad config and a temporary keyring as well.

This manager can be used to deploy or manipulate credentials within the scope of a single test.

datalad_next.tests.fixtures.datalad_cfg()[source]

Temporarily alter configuration to use a plain "global" configuration

The global configuration manager at datalad.cfg is reloaded after adjusting GIT_CONFIG_GLOBAL to point to a new temporary .gitconfig file.

After test execution the file is removed, and the global ConfigManager is reloaded once more.

Any test using this fixture will be skipped for Git versions earlier than 2.32, because the GIT_CONFIG_GLOBAL environment variable used here was only introduced with that version.

datalad_next.tests.fixtures.datalad_interactive_ui(monkeypatch)[source]

Yields a UI replacement to query for operations and stage responses

No output will be written to STDOUT/ERR by this UI.

A standard usage pattern is to stage one or more responses, run the to-be-tested code, and verify that the desired user interaction took place:

> datalad_interactive_ui.staged_responses.append('skip')
> ...
> assert ... datalad_interactive_ui.log
datalad_next.tests.fixtures.datalad_noninteractive_ui(monkeypatch)[source]

Yields a UI replacement to query for operations

No output will be written to STDOUT/ERR by this UI.

A standard usage pattern is to run the to-be-tested code, and verify that the desired user messaging took place:

> ...
> assert ... datalad_interactive_ui.log
datalad_next.tests.fixtures.dataset(datalad_cfg, tmp_path_factory)[source]

Provides a Dataset instance for a not-yet-existing repository

The instance points to an existing temporary path, but create() has not been called on it yet.

datalad_next.tests.fixtures.existing_dataset(dataset)[source]

Provides a Dataset instance pointing to an existing dataset/repo

This fixture uses an instance provided by the dataset fixture and calls create() on it, before it yields the Dataset instance.

datalad_next.tests.fixtures.existing_noannex_dataset(dataset)[source]

just like existing_dataset, but created with annex=False

datalad_next.tests.fixtures.http_credential()[source]

Provides the HTTP Basic authentication credential necessary to access the HTTP server provided by the http_server_with_basicauth fixture.

datalad_next.tests.fixtures.http_server(tmp_path_factory)[source]

Provides an HTTP server, serving a temporary directory

The fixtures yields an instance of HTTPPath, providing the following essential attributes:

  • path: Path instance of the served temporary directory

  • url: HTTP URL to access the HTTP server

datalad_next.tests.fixtures.http_server_with_basicauth(tmp_path_factory, http_credential)[source]

Like http_server but requiring authentication via http_credential

datalad_next.tests.fixtures.httpbin(httpbin_service)[source]

Does the same thing as httpbin_service, but skips on function-scope

httpbin_service always returns access URLs for HTTPBIN. However, in some cases it is simply not desirable to run a test. For example, the appveyor workers are more or less constantly unable to access the public service. This fixture is evaluated at function-scope and raises SkipTest whenever any of these undesired conditions is detected. Otherwise it just relays httpbin_service.

datalad_next.tests.fixtures.httpbin_service()[source]

Return canonical access URLs for the HTTPBIN service

This fixture tries to spin up a httpbin Docker container at localhost:8765; if successful, it returns this URL as the 'standard' URL. If the attempt fails, a URL pointing to the canonical instance is returned.

For tests that need to have the service served via a specific protocol (https vs http), the corresponding URLs are returned too. They always point to the canonical deployment, as some tests require both protocols simultaneously and a local deployment generally won't have https.

datalad_next.tests.fixtures.tmp_keyring()[source]

Patch plaintext keyring to temporarily use a different storage

No credential read or write actions will impact any existing credential store of any configured backend.

The patched backend is yielded by the fixture.

datalad_next.tests.fixtures.webdav_credential()[source]

Provides HTTP Basic authentication credential necessary to access the server provided by the webdav_server fixture.

datalad_next.tests.fixtures.webdav_server(tmp_path_factory, webdav_credential)[source]

Provides a WebDAV server, serving a temporary directory

The fixtures yields an instance of WebDAVPath, providing the following essential attributes:

  • path: Path instance of the served temporary directory

  • url: HTTP URL to access the WebDAV server

Server access requires HTTP Basic authentication with the credential provided by the webdav_credential fixture.