The saliweb.test
Python module¶
Utility classes and functions to aid in testing Sali lab web services.
- saliweb.test.tmpdir¶
The full path to the temporary directory.
- class saliweb.test.MockJob(name, directory)¶
A temporary job for testing web service results pages. Create by calling
make_frontend_job()
.- directory = None¶
Temporary directory containing result files (see
make_file()
)
- make_file(name, contents='')¶
Make a file in the job’s directory with the given contents
- name = None¶
Job name
- passwd = None¶
Password needed to construct URLs for this job
- class saliweb.test.TestCase(methodName='runTest')¶
Custom TestCase subclass for testing Sali web service backends
- get_test_directory()¶
Get the full path to the directory containing test scripts. This can be useful for getting supplemental files needed by tests, which can be stored in a subdirectory of the test directory.
- make_test_job(jobcls, state)¶
Make a test job of the given class in the given state (e.g. RUNNING, POSTPROCESSING) and return the new object. A temporary directory is created for the job to use (as Job.directory) and will be deleted automatically once the object is destroyed.
- saliweb.test.get_modeller_key()¶
Get a valid mock Modeller key for testing
- saliweb.test.import_mocked_frontend(pkgname, test_file, topdir)¶
Import the named frontend module (e.g. ‘modloop’), and return it. This sets up the environment with mocked configuration so that the module can be tested without being installed and without a live database. For this to work properly, it should be called before importing saliweb.frontend.
- saliweb.test.make_frontend_job(name)¶
Context manager to make a temporary job. See
MockJob
. This can be used to test the job results page and the download of results files.
- saliweb.test.temporary_working_directory()¶
Simple context manager to run in a temporary directory. While the context manager is active (within the ‘with’ block) the current working directory is set to a temporary directory. When the context manager exists, the working directory is reset and the temporary directory deleted.
- saliweb.test.working_directory(workdir)¶
Context manager to temporarily set the working directory. While the context manager is active (within the ‘with’ block) the current working directory is set to workdir. When the context manager exists, the working directory is reset.