diff --git a/pylabrobot/resources/tip_tracker.py b/pylabrobot/resources/tip_tracker.py index 1a876ce86f5..4b1ee76b92c 100644 --- a/pylabrobot/resources/tip_tracker.py +++ b/pylabrobot/resources/tip_tracker.py @@ -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.""" diff --git a/pylabrobot/resources/tip_tracker_tests.py b/pylabrobot/resources/tip_tracker_tests.py index dabd924a528..6fff42bb598 100644 --- a/pylabrobot/resources/tip_tracker_tests.py +++ b/pylabrobot/resources/tip_tracker_tests.py @@ -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()