Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pylabrobot/resources/tip_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def has_tip(self) -> bool:
return self._pending_tip is not None

def get_tip(self) -> "Tip":
"""Get the tip. Note that does includes pending operations.
"""Get the tip. Note that this includes pending operations.

Raises:
NoTipError: If the tip spot does not have a tip.
"""

if self._tip is None:
if self._pending_tip is None:
raise NoTipError(f"{self.thing} does not have a tip.")
return self._tip
return self._pending_tip

def disable(self) -> None:
"""Disable the tip tracker."""
Expand Down
14 changes: 14 additions & 0 deletions pylabrobot/resources/tip_tracker_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ def test_remove_tip(self):

with self.assertRaises(NoTipError):
tracker.get_tip()

def test_get_tip_includes_pending_add(self):
tracker = TipTracker(thing="tester")
tracker.add_tip(self.tip, commit=False)
self.assertEqual(tracker.has_tip, True)
self.assertEqual(tracker.get_tip(), self.tip)

def test_get_tip_includes_pending_remove(self):
tracker = TipTracker(thing="tester")
tracker.add_tip(self.tip)
tracker.remove_tip(commit=False)
self.assertEqual(tracker.has_tip, False)
with self.assertRaises(NoTipError):
tracker.get_tip()
Loading