schrodinger.application.msv.test_helpers module

class schrodinger.application.msv.test_helpers.AlignmentInfo(seqs=(), locked_columns=(), potential_reordering=None)

Bases: future.types.newobject.newobject

class schrodinger.application.msv.test_helpers.RuleBasedStateMachineMetaClass

Bases: type

A metaclass that makes it easy to create simple rules for a RuleBasedStateMachine.

‘Simple’ in this context means that the rule we want to create
  1. calls a method that takes no argument, and then
  2. doesn’t check any results

The only thing that we’re testing with a rule like this is that calling the method never results in an unhandled exception. Ideally, we would check the results of calling methods, but even the lazy route is surprisingly useful in a state machine test. Advice: begin by adding as many of these simple rules as possible and then gradually replace them with richer rules and checks as the tests develop and experience indicates which checks are most valuable.

Suppose that we are testing self.panel in our state machine and want to call the methods ‘foo’ on self.panel.bar and ‘gar’ on self.panel.mar. We could write this:

class PanelMachine(stateful.RuleBaseStateMachine):
def __init__(self):
super(PanelMachine, self).__init__() self.panel = MyPanel()

@stateful.rule() def foo(self):

self.panel.bar.foo()

@stateful.rule() def gar(self):

self.panel.mar.gar()

But this quickly becomes tedious if we want to test a large number of such methods. Our metaclass will allow us to generate the desired rules for our state machine by adding strings to the SIMPLE_RULES tuple defined on the class:

@six.add_metaclass(RuleBasedStateMachineMetaClass) class PanelMachine(stateful.RuleBaseStateMachine):

SIMPLE_RULES = (‘panel.bar.foo’, ‘panel.bar.gar’)

def __init__(self):
super(PanelMachine, self).__init__() self.panel = MyPanel()
class schrodinger.application.msv.test_helpers.StandaloneStructureModelWithWorkspace(parent)

Bases: schrodinger.application.msv.structure_model.StandaloneStructureModel

A structure model with a fake workspace alignment so we can test how the MSV panel will respond when run inside Maestro. Used in TestMSVPanelWithWorkspaceTab.

getWorkspaceAlignment()
schrodinger.application.msv.test_helpers.alignment_info_strategy()

Returns everything we need to create an alignment

We return an alignment_info instead of an alignment in order to allow tests to create different kinds of alignments and also to pass along additional test data customized to the alignment that the test will create. For example, a potential_reordering will be a reordering that should work with the alignment, etc., etc.

Returns:A test fixture for alignment tests
Return type:AlignmentInfo
schrodinger.application.msv.test_helpers.generated_residues(residue_types=None)
Parameters:
  • draw (function) – A function supplied by hypothesis
  • residue_types (list(residue.ElementType)) – Alphabet to use for residues. By default, it will use 95% standard and 5% nonstandard protein amino acids.
Returns:

A residue suitable for testing

Return type:

schrodinger.protein.residue.Residue

schrodinger.application.msv.test_helpers.generated_sequences(min_size=None, average_size=20, max_size=None, residue_types=None, patch=True)
Parameters:
  • draw (function) – A function supplied by hypothesis
  • min_size (int) – Minimum length for sequences
  • average_size (int) – Average length for sequences.
  • max_size (int) – Maximum length for sequences
  • residue_types (list(residue.ElementType)) – Alphabet to use for residues
  • patch (bool) – Whether to patch the signals on the sequence instance
Returns:

A protein sequence suitable for testing

Return type:

schrodinger.protein.sequence.ProteinSequence

schrodinger.application.msv.test_helpers.make_alignment(AlnClass, aln_info, patch=True)

Given an alignment class and information to populate an instance returns an instance of an alignment

Parameters:
  • AlnClass (type) – An alignment class
  • aln_info (AlignmentInfo) – Information to populate the instance
  • patch (bool) – Whether to patch the signals on the alignment instance
Returns:

A ProteinAlignment instance.

Return type:

alignment.ProteinAlignment

schrodinger.application.msv.test_helpers.patch_signals(obj)

Patch all the signals on the given object with MagicMocks.

Parameters:obj (object) – The object whose signals we want to patch
schrodinger.application.msv.test_helpers.qcolor_strategy()
Returns:A QtColor instance to be used in a test
Return type:QtGui.QColor