Skip to content

Commit

Permalink
Check that the length of input and replicates is the same
Browse files Browse the repository at this point in the history
defaults to replicates=1
  • Loading branch information
tcezard committed Jul 12, 2017
1 parent ac977de commit c334fd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pyclarity_lims/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ def set_placements(self, output_containers, output_placement_list):
self.placement.root = self.placement.post()

@classmethod
def create(cls, lims, protocol_step, inputs, container_type_name=None, reagent_category=None, replicates=None, **kwargs):
def create(cls, lims, protocol_step, inputs, container_type_name=None, reagent_category=None, replicates=1, **kwargs):
"""
Create a new instance of a Step. This method will start a step from queued artifacts.
Expand Down Expand Up @@ -913,6 +913,7 @@ def create(cls, lims, protocol_step, inputs, container_type_name=None, reagent_c

if isinstance(replicates, int):
replicates = [replicates] * len(inputs)
assert len(replicates) == len(inputs)
inputs_node = ElementTree.SubElement(instance.root, 'inputs')
for i, artifact in enumerate(inputs):
if not isinstance(artifact, Artifact):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ def test_create2(self):
)
with patch('pyclarity_lims.lims.requests.post',
return_value=Mock(content=self.step_xml, status_code=201)) as patch_post:
Step.create(self.lims, protocol_step=protocol_step, inputs=inputs, replicates=1)
# replicates default to 1
Step.create(self.lims, protocol_step=protocol_step, inputs=inputs)
data = '''<?xml version='1.0' encoding='utf-8'?>
<stp:step-creation xmlns:stp="http://genologics.com/ri/step">
<configuration uri="http://testgenologics.com:4040/api/v2/configuration//protocols/p1/steps/p1s1">
Expand Down

0 comments on commit c334fd9

Please sign in to comment.