Skip to content

Commit

Permalink
Correcting behaviour of XmlList.__iadd__, reagent label doc link
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhamgenomics committed May 4, 2018
1 parent 4ce15e6 commit 8fbe4dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion pyclarity_lims/descriptors.py
Expand Up @@ -449,7 +449,11 @@ def __add__(self, other_list):
self._update_elems()
return list.__add__(self, [self._modify_value_before_insert(v, len(self) + i) for i, v in enumerate(other_list)])

__iadd__ = __add__
def __iadd__(self, other_list):
for item in other_list:
self._additem(item)
self._update_elems()
return list.__iadd__(self, [self._modify_value_before_insert(v, len(self) + i) for i, v in enumerate(other_list)])

def __setitem__(self, i, item):
if isinstance(i, slice):
Expand Down
10 changes: 5 additions & 5 deletions pyclarity_lims/entities.py
Expand Up @@ -563,7 +563,7 @@ class Artifact(Entity):
files = EntityListDescriptor(nsmap('file:file'), File)
"""List of :py:class:`files <pyclarity_lims.entities.File>` associated with the artifact."""
reagent_labels = ReagentLabelList()
"""List of :py:class:`Reagent labels <pyclarity_lims.entities.ReagentLabel>` associated with the artifact."""
"""List of :py:class:`Reagent labels <pyclarity_lims.entities.Reagent_label>` associated with the artifact."""
workflow_stages = None # See bottom of the file
"""List of workflow stage :py:class:`Steps <pyclarity_lims.entities.Step>` that this artifact ran through."""

Expand Down Expand Up @@ -898,10 +898,10 @@ def set_placements(self, output_containers, output_placement_list):
- C is a string specifying the location in the container such as "1:1"
"""
self.placement = StepPlacements(self.lims, uri=self.uri + '/placements')
self.placement.selected_containers = output_containers
self.placement.placement_list = output_placement_list
self.placement.root = self.placement.post()
self.placements = StepPlacements(self.lims, uri=self.uri + '/placements')
self.placements.selected_containers = output_containers
self.placements.placement_list = output_placement_list
self.placements.root = self.placements.post()

@classmethod
def create(cls, lims, protocol_step, inputs, container_type_name=None, reagent_category=None, replicates=1, **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_descriptors.py
Expand Up @@ -619,11 +619,14 @@ def test___add__(self):

def test__iadd__(self):
el1 = EntityList(self.instance1, 'artifact', Artifact)
id1 = id(el1)
assert len(el1) == 2
assert len(el1.instance.root.findall('artifact')) == 2
el2 = [Artifact(self.lims, id='a3'), Artifact(self.lims, id='a4')]

el1 += el2
id2 = id(el1)
assert id1 == id2 # still the same object
assert len(el1) == 4
assert el1[2:] == el2

Expand Down

0 comments on commit 8fbe4dd

Please sign in to comment.