def test_stp(self): """ Test for Sets Spanning Tree Protocol state for a bridge """ with patch.dict(bridge.__grains__, {"kernel": "Linux"}): mock = MagicMock(return_value="Linux") with patch.object(bridge, "_os_dispatch", mock): self.assertEqual(bridge.stp(), "Linux") with patch.dict(bridge.__grains__, {"kernel": "FreeBSD"}): mock = MagicMock(return_value="FreeBSD") with patch.object(bridge, "_os_dispatch", mock): self.assertEqual(bridge.stp(), "FreeBSD") with patch.dict(bridge.__grains__, {"kernel": None}): self.assertFalse(bridge.stp())
def test_stp(self): ''' Test for Sets Spanning Tree Protocol state for a bridge ''' with patch.dict(bridge.__grains__, {'kernel': 'Linux'}): mock = MagicMock(return_value='Linux') with patch.object(bridge, '_os_dispatch', mock): self.assertEqual(bridge.stp(), 'Linux') with patch.dict(bridge.__grains__, {'kernel': 'FreeBSD'}): mock = MagicMock(return_value='FreeBSD') with patch.object(bridge, '_os_dispatch', mock): self.assertEqual(bridge.stp(), 'FreeBSD') with patch.dict(bridge.__grains__, {'kernel': None}): self.assertFalse(bridge.stp())