def test_isExclusionEnabled_enabled(self): """Test the isExclusionEnabled method when exclusion is enabled.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) self.assertTrue(unit.isExclusionEnabled(), "isExclusionEnabled should report True")
def test_isExclusionEnabled_disabled(self): """Test the isExclusionEnabled method when exclusion is disabled.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.disableExclusion("Disable for test") self.assertFalse(unit.isExclusionEnabled(), "isExclusionEnabled should report False")
def test_enableExclusion_exclusionDisabled(self): """Test the enableExclusion method when exclusion is disabled.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.disableExclusion("Disable for test") unit.enableExclusion("Re-enable for test") self.assertTrue(unit.isExclusionEnabled(), "isExclusionEnabled should report True")
def test_enableExclusion_exclusionEnabled(self): """Test the enableExclusion method when exclusion is already enabled.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.enableExclusion("Redundant enable for test") mockLogger.debug.assert_called_with( RegexMatcher("^Exclusion already enabled"), mock.ANY) self.assertTrue(unit.isExclusionEnabled(), "isExclusionEnabled should report True")
def test_disableExclusion_exclusionEnabled_notExcluding( self, mockExitExcludedRegion): """Test the disableExclusion method when exclusion is enabled and not excluding.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) returnedCommands = unit.disableExclusion("Disable for test") self.assertFalse(unit.isExclusionEnabled(), "isExclusionEnabled should report False") mockExitExcludedRegion.assert_not_called() self.assertEqual(returnedCommands, [], "An empty list of commands should be returned")
def test_disableExclusion_exclusionEnabled_excluding( self, mockExitExcludedRegion): """Test the disableExclusion method when exclusion is enabled and currently excluding.""" mockExitExcludedRegion.return_value = ["ABC"] mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.excluding = True returnedCommands = unit.disableExclusion("Redundant disable for test") self.assertFalse(unit.isExclusionEnabled(), "isExclusionEnabled should report False") mockExitExcludedRegion.assert_called_with("Redundant disable for test") self.assertEqual( returnedCommands, ["ABC"], "The commands returned by exitExcludeRegion should be returned")
def test_disableExclusion_exclusionDisabled(self, mockExitExcludedRegion): """Test the disableExclusion method when exclusion is already disabled.""" mockLogger = mock.Mock() unit = ExcludeRegionState(mockLogger) unit.disableExclusion("Initial disable for test") mockLogger.reset_mock() returnedCommands = unit.disableExclusion( "Second disable call, should be ignored") mockLogger.debug.assert_called_with( RegexMatcher("^Exclusion already disabled"), mock.ANY) mockExitExcludedRegion.assert_not_called() self.assertFalse(unit.isExclusionEnabled(), "isExclusionEnabled should report False") self.assertEqual(returnedCommands, [], "An empty list of commands should be returned")