one.tests.test_one
Unit tests for the one.api module.
Wherever possible the ONE tests should not rely on an internet connection.
Fixture locations:
The cache tables for the public test instance are in tests/fixtures/
The test db parameters can be found in tests/fixtures/params/
Some REST GET requests can be found in tests/fixtures/rest_responses/
These can be copied over to a temporary directory using the functions in tests/util.py, then construct ONE with the directory as cache_dir, mode=’local’ and silent=True
Imported constants:
For tests that do require a remote connection use the tests.OFFLINE_ONLY flag in the skipIf decorator.
For testing REST POST requests use TEST_DB_1 (test.alyx.internationalbrainlab.org).
For testing download functions, use TEST_DB_2 (openalyx.internationalbrainlab.org).
Note ONE and AlyxClient use caching:
When verifying remote changes via the rest method, use the no_cache flag to ensure the remote databaseis queried. You can clear the cache using AlyxClient.clear_rest_cache(), or mock iblutil.io.params.getfile to return a temporary cache directory.
An One object created through the one.api.ONE function, make sure you restore the properties to their original state on teardown, or call one.api.ONE.cache_clear().
Classes
Test methods that use sessions and datasets tables. |
|
This could be an offline test. |
|
Test downloading datasets using OpenAlyx. |
|
Test functions in one.util. |
|
Test remote queries using OpenAlyx |
|
Test parameter setup upon ONE instantiation and calling setup methods. |
- class TestONECache(methodName='runTest')[source]
Bases:
TestCase
Test methods that use sessions and datasets tables. This class loads the parquet tables from the fixtures and builds a file tree in a temp folder
- tempdir = None
- class TestOneAlyx(methodName='runTest')[source]
Bases:
TestCase
This could be an offline test. Would need to add /docs REST cache fixture.
- tempdir = None
- one = None
- classmethod setUpClass() None [source]
Hook method for setting up class fixture before running tests in the class.
- test_describe_dataset(mock_stdout)[source]
Test OneAlyx.describe_dataset. NB This could be offline: REST responses in fixtures.
- class TestOneRemote(methodName='runTest')[source]
Bases:
TestCase
Test remote queries using OpenAlyx
- class TestOneDownload(methodName='runTest')[source]
Bases:
TestCase
Test downloading datasets using OpenAlyx.
- tempdir = None
- one = None
- class TestOneSetup(methodName='runTest')[source]
Bases:
TestCase
Test parameter setup upon ONE instantiation and calling setup methods.
- test_setup_silent()[source]
Test setting up parameters with silent flag.
Mock getfile to return temp dir as param file location
Mock input function as fail safe in case function erroneously prompts user for input