one.tests.util
Utilities functions for setting up test fixtures.
Functions
Convert str ids to int ids for cache tables. |
|
Touch all the files in the datasets table. |
|
Save REST cache file for docs/ endpoint. |
|
A stub function for iblutil.io.params.getfile. |
|
Returns a datasets cache DataFrame containing datasets with revision folders. |
|
Create a temporary directory and copy cache fixtures over. |
|
Copy REST cache fixtures to the .one parameter directory. |
|
Copies cache parameter fixture to .one directory. |
- set_up_env() TemporaryDirectory [source]
Create a temporary directory and copy cache fixtures over.
- Returns:
The temporary directory containing the test ONE caches
- Return type:
tempfile.TemporaryDirectory
- setup_rest_cache(cache_dir)[source]
Copy REST cache fixtures to the .one parameter directory.
- Parameters:
cache_dir (str, pathlib.Path) – The location of the ONE cache directory (e.g. ~/Downloads/ONE/alyx.example.com)
- create_file_tree(one)[source]
Touch all the files in the datasets table.
- Parameters:
one (one.api.One) – An instance of One containing cache tables to use.
- setup_test_params(token=False, cache_dir=None)[source]
Copies cache parameter fixture to .one directory.
- Parameters:
token (bool) – If true, save a token file so that client doesn’t hit auth endpoint
cache_dir (str, pathlib.Path) – The cache_dir to save
- revisions_datasets_table(collections=('', 'alf/probe00', 'alf/probe01'), revisions=('', '2020-01-08', '2021-07-06'), object='spikes', attributes=('times', 'waveforems'), touch_path=None)[source]
Returns a datasets cache DataFrame containing datasets with revision folders.
As there are no revised datasets on the test databases, this function acts as a fixture for testing the filtering of datasets by a revision.
- Parameters:
collections (tuple) – A list of collections
revisions (tuple) – A list of revisions
object (str) – An ALF object
attributes (tuple) – A list of ALF attributes
touch_path (pathlib.Path, str) – If provided, files are created in this directory.
- Returns:
A datasets cache table containing datasets made from the input names.
- Return type:
pd.DataFrame
- create_schema_cache(param_dir=None)[source]
Save REST cache file for docs/ endpoint.
Ensures the database isn’t hit when the rest_schemas property is accessed.
- Parameters:
param_dir (str, pathlib.Path) – The location of the parameter directory. If None, the default one is used.
- get_file(root: str, str_id: str) str [source]
A stub function for iblutil.io.params.getfile. Allows the injection of a different param dir.
- Parameters:
root (str, pathlib.Path) – The root directory of the new parameters
str_id (str) – The parameter string identifier
- Returns:
The parameter file path
- Return type:
str