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 skips the test 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.modified_dataset(tmp_path_factory)[source]

Produces a dataset with various modifications

The fixture is module-scope, aiming to be reused by many tests focused on reporting. It does not support any further modification. The fixture will fail, if any such modification is detected.

git status will report:

❯ git status -uall
On branch dl-test-branch
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   dir_m/file_a
        new file:   file_a

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        deleted:    dir_d/file_d
        deleted:    dir_m/file_d
        modified:   dir_m/file_m
        deleted:    dir_sm/sm_d
        modified:   dir_sm/sm_m (modified content)
        modified:   dir_sm/sm_mu (modified content, untracked content)
        modified:   dir_sm/sm_n (new commits)
        modified:   dir_sm/sm_nm (new commits, modified content)
        modified:   dir_sm/sm_nmu (new commits, modified content, untracked content)
        modified:   dir_sm/sm_u (untracked content)
        deleted:    file_d
        modified:   file_m

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        dir_m/dir_u/file_u
        dir_m/file_u
        dir_u/file_u
        file_u

Suffix indicates the ought-to state (multiple possible):

a - added c - clean d - deleted n - new commits m - modified u - untracked content

Prefix indicated the item type:

file - file sm - submodule dir - directory

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

Disable datalad command result rendering for all command calls

This is achieved by forcefully supplying result_renderer='disabled' to any command call via a patch to internal argument normalizer get_allargs_as_kwargs().

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

Reduce the logging output during test runs

DataLad emits a large amount of repetitive INFO log messages that only clutter the test output, and hardly ever help to identify an issue. This fixture modifies the standard logger to throw away all INFO level log messages.

With this approach, such messages are still fed to and processes by the logger (in contrast to an apriori level setting).

datalad_next.tests.fixtures.sshserver(sshserver_setup, datalad_cfg, monkeypatch)[source]
datalad_next.tests.fixtures.sshserver_setup(tmp_path_factory)[source]
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.