schrodinger.test.mock_ld_client module¶
-
class
schrodinger.test.mock_ld_client.MockLDClient(*args, user_name='Sam', version_string='8.1.0-SNAPSHOT', host='https://unit_test-8-5.dev.bb.schrodinger.com')[source]¶ Bases:
object-
__init__(*args, user_name='Sam', version_string='8.1.0-SNAPSHOT', host='https://unit_test-8-5.dev.bb.schrodinger.com')[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
live_report(lr_id)[source]¶ Return the live report model associated with the specified live report ID, if possible.
- Raises
HTTPError – if no live report on the server has the specified live report ID
- Parameters
lr_id (str) – a live report ID (string representation of a nonnegative integer)
- Returns
a live report, if possible
- Return type
-
setFolderTreeData(data)[source]¶ Set the value returned by
get_folder_tree_data().This is a test method that does not correspond to a
LDClientmethod.
-
get_subfolders(folder_name, data)[source]¶ Return specified subfolders.
This method closely reproduces the behavior of the corresponding
LDClientmethod.
-
get_project_id_by_name(project_name)[source]¶ - Parameters
project_name (str) – the name of a project on the LD server
- Returns
the project ID associated with the specified project; if none is found, return an empty list (LDIDEAS-2910)
- Return type
int or list
-
get_protocol_id_by_name(protocol_name)[source]¶ - Parameters
protocol_name (str) – the name of a protocol on the LD server
- Returns
the protocol ID associated with the specified protocol; if none is found, return an empty list (LDIDEAS-2910)
- Return type
int or list
-
property
live_report_ids¶
-
property
mode¶
-
setMode(mode)[source]¶ Set the mode for this LD client instance.
This method is for testing purposes only, and has no analog in
LDClient.- Parameters
mode (login.LDMode or str) – the new mode for this instance; must be one of the values defined in
login.LDModeor the string equivalent of same
-
addProject(project_name, project_id=None)[source]¶ Add a project to the dictionary of projects stored on this client.
This method is for testing purposes only, and has no analog in
LDClient.- Raises
ValueError – if a non-unique name or ID is supplied
- Parameters
project_name (str) – the name of the new project
project_id (int or NoneType) – optionally, the ID of the new project; if none is supplied, a unique ID will be generated automatically
-
addProtocol(protocol)[source]¶ Add a protocol to the dictionary of protocols stored on this client.
This method is for testing purposes only, and has no analog in
LDClient.- Raises
ValueError – if a protocol with a non-unique ID is supplied
- Parameters
protocol (mock_ld_models.Model) – a protocol
-
property
version_string¶
-
list_users()[source]¶ - Returns
a list of dictionaries containing data about users registered to the server
- Return type
list(dict)
-
setFreeformColumns(freeform_columns)[source]¶ A convenience method for this mock that does not have an equivalent in the actual
LDClientclass. Set the freeform columns on this mocked LiveDesign server.- Parameters
freeform_columns (list(mock_ld_models.MockFFC)) – a list of freeform columns
-
create_freeform_column(freeform_column)[source]¶ Add the supplied column to the LiveDesign server, but not to any specific live report.
- Parameters
freeform_column (mock_ld_models.MockFFC) – a freeform column
- Returns
the supplied freeform column
- Return type
mock_ld_models.MockFFC
-
add_columns(live_report_id, column_ids)[source]¶ Add the supplied list of columns to the specified live report.
- Raises
TypeError – if the supplied live report ID is not a string
ValueError – if a column hasn’t been created on this server yet
- Parameters
live_report_id (str) – a live report ID
column_ids (list(int)) – a list of column IDs corresponding to columns that should be added to the live report
-
wait_and_get_result_url(task_id, timeout=1200)[source]¶ Wait on a running asynchronous task and return relevent data when it completes.
- Raises
Exception – when timeout elapses before task completes (for the purposes of this mock, an exception will be raised if
task_id='timeout')ldclient.models.AsyncServiceTaskFailedError – when the status from a completed task is not ‘finished’ (for the purposes of this mock, an exception will be raised if
task_id='error')
- Parameters
task_id (str) – ID of an asynchronous task
timeout (int) – time (in seconds) to wait before raising an exception
- Returns
the path associated with the asynchronous task
- Return type
str
-
get_task_result(result_url)[source]¶ Given the URL for a completed task, return a data dictionary containing information about that task.
- Parameters
result_url (str) – the path associated with the completed task; should be the output from
wait_and_get_result_url()- Returns
a data dictionary from the completed task
- Return type
dict(str, object)
-
setTaskResult(result)[source]¶ Set the value that will be returned by
get_task_result().This is a debugging method that has no equivalent in
LDClient.- Parameters
result (dict[str, object] or NoneType) – the result dictionary to return from the method
get_task_result(). Setting this value toNonereverts theget_task_result()return value to a minimal default dictionary.
-
getLRColumns(live_report_id)[source]¶ Return all columns that have been added to the specified live report.
- Parameters
live_report_id (str) – a live report ID
- Returns
the columns associated with the specified live report
- Return type
list(mock_ld_models.MockFFC)
-
get_or_create_attachment(attachment_file_name, file_type, project_ids, file_obj=None, alternate_id=None, remote_file_name=None)[source]¶ Find or create an attachment, then return a data dictionary.
-
create_model(model)[source]¶ Mimic the behavior of
LDClient.create_model()by simply adding the supplied model to the set of known models.If no model ID is defined, assign one.
- Raises
ValueError – if the supplied model has a non-unique ID
- Parameters
model (mock_ld_models.Model) – a model
-
models()[source]¶ Convenience method to return all stored models.
This method is for testing purposes only, and has no analog in
LDClient.- Returns
models stored on this object
- Return type
list[mock_ld_models.Model]
-
attachmentSettings()[source]¶ Convenience method to return all stored attachment settings maps.
This method is for testing purposes only, and has no analog in
LDClient.- Returns
all attachment settings maps stored on this object
- Return type
list[dict[str, str]]
-
-
schrodinger.test.mock_ld_client.get_standard_protocols()[source]¶ - Returns
a list of standard LD protocol mocks
- Return type
list[mock_ld_models.Model]