def test_basic(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock(reload='reload', config=config.Config()) control.reload(daemon) self.assertFalse(mock_random.called) self.assertFalse(mock_spawn_after.called) mock_spawn_n.assert_called_once_with('reload')
def test_forced_spread(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock(reload='reload', config=config.Config()) control.reload(daemon, 'spread', '20.4') mock_random.assert_called_once_with() mock_spawn_after.assert_called_once_with(10.2, 'reload') self.assertFalse(mock_spawn_n.called)
def test_bad_spread_fallback(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock(reload='reload', config=config.Config(conf_dict={ 'control.reload_spread': '40.8', })) control.reload(daemon, 'spread', '20.4.3') mock_random.assert_called_once_with() mock_spawn_after.assert_called_once_with(20.4, 'reload') self.assertFalse(mock_spawn_n.called)
def test_configured_spread_override(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock(reload='reload', config=config.Config(conf_dict={ 'control.reload_spread': '20.4', })) control.reload(daemon, 'immediate') self.assertFalse(mock_random.called) self.assertFalse(mock_spawn_after.called) mock_spawn_n.assert_called_once_with('reload')
def test_configured_spread(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock(reload='reload', config=config.Config(conf_dict={ 'control.reload_spread': '20.4', })) control.reload(daemon) mock_random.assert_called_once_with() mock_spawn_after.assert_called_once_with(10.2, 'reload') self.assertFalse(mock_spawn_n.called)
def test_bad_spread_fallback(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock( reload='reload', config=config.Config(conf_dict={ 'control.reload_spread': '40.8', })) control.reload(daemon, 'spread', '20.4.3') mock_random.assert_called_once_with() mock_spawn_after.assert_called_once_with(20.4, 'reload') self.assertFalse(mock_spawn_n.called)
def test_configured_spread_override(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock( reload='reload', config=config.Config(conf_dict={ 'control.reload_spread': '20.4', })) control.reload(daemon, 'immediate') self.assertFalse(mock_random.called) self.assertFalse(mock_spawn_after.called) mock_spawn_n.assert_called_once_with('reload')
def test_configured_spread(self, mock_random, mock_spawn_n, mock_spawn_after): daemon = mock.Mock( reload='reload', config=config.Config(conf_dict={ 'control.reload_spread': '20.4', })) control.reload(daemon) mock_random.assert_called_once_with() mock_spawn_after.assert_called_once_with(10.2, 'reload') self.assertFalse(mock_spawn_n.called)