def test_getRegion_notExists(self): """Test the getRegion method when no such region is defined.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) self.assertIsNone( unit.getRegion("someId"), "getRegion return None when the region isn't defined")
def test_getRegion_exists(self): """Test the getRegion method when a matching region has been defined.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) aRegion = RectangularRegion(x1=0, y1=0, x2=100, y2=100, id="anId") otherRegion = RectangularRegion(x1=10, y1=10, x2=20, y2=20, id="otherId") unit.addRegion(aRegion) unit.addRegion(otherRegion) self.assertIs( unit.getRegion("anId"), aRegion, "getRegion return the region matching the id when such a region is defined" ) self.assertIs( unit.getRegion("otherId"), otherRegion, "getRegion return the region matching the id when such a region is defined" )