-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue#743: fetch.ubuntu._run_with_retries raises on unexpected exitcode #744
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,47 +46,56 @@ def test_register_preserves_order(self): | |
@mock.patch.object(services.ServiceManager, 'reconfigure_services') | ||
@mock.patch.object(services.ServiceManager, 'stop_services') | ||
@mock.patch.object(hookenv, 'hook_name') | ||
@mock.patch.object(hookenv, 'config') | ||
def test_manage_stop(self, config, hook_name, stop_services, reconfigure_services): | ||
@mock.patch.object(hookenv, '_run_atstart') | ||
@mock.patch.object(hookenv, 'config', mock.Mock()) | ||
def test_manage_stop(self, _run_atstart, hook_name, stop_services, reconfigure_services): | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adjust most of the |
||
manager = services.ServiceManager() | ||
hook_name.return_value = 'stop' | ||
manager.manage() | ||
_run_atstart.assert_called_once_with() | ||
stop_services.assert_called_once_with() | ||
assert not reconfigure_services.called | ||
|
||
@mock.patch.object(services.ServiceManager, 'provide_data') | ||
@mock.patch.object(services.ServiceManager, 'reconfigure_services') | ||
@mock.patch.object(services.ServiceManager, 'stop_services') | ||
@mock.patch.object(hookenv, 'hook_name') | ||
@mock.patch.object(hookenv, 'config') | ||
def test_manage_other(self, config, hook_name, stop_services, reconfigure_services, provide_data): | ||
@mock.patch.object(hookenv, '_run_atstart') | ||
@mock.patch.object(hookenv, 'config', mock.Mock()) | ||
def test_manage_other(self, _run_atstart, hook_name, stop_services, reconfigure_services, provide_data): | ||
manager = services.ServiceManager() | ||
hook_name.return_value = 'config-changed' | ||
manager.manage() | ||
_run_atstart.assert_called_once_with() | ||
assert not stop_services.called | ||
reconfigure_services.assert_called_once_with() | ||
provide_data.assert_called_once_with() | ||
|
||
@mock.patch.object(hookenv, '_atstart', []) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. except for the |
||
def test_manage_calls_atstart(self): | ||
cb = mock.MagicMock() | ||
hookenv.atstart(cb) | ||
manager = services.ServiceManager() | ||
manager.manage() | ||
self.assertTrue(cb.called) | ||
|
||
def test_manage_calls_atexit(self): | ||
@mock.patch.object(hookenv, '_run_atstart') | ||
def test_manage_calls_atexit(self, _run_atstart): | ||
cb = mock.MagicMock() | ||
hookenv.atexit(cb) | ||
manager = services.ServiceManager() | ||
manager.manage() | ||
_run_atstart.assert_called_once_with() | ||
self.assertTrue(cb.called) | ||
|
||
@mock.patch.object(hookenv, 'config') | ||
def test_manage_config_not_saved(self, config): | ||
@mock.patch.object(hookenv, '_run_atstart') | ||
def test_manage_config_not_saved(self, _run_atstart, config): | ||
config = config.return_value | ||
config.implicit_save = False | ||
manager = services.ServiceManager() | ||
manager.manage() | ||
_run_atstart.assert_called_once_with() | ||
self.assertFalse(config.save.called) | ||
|
||
@mock.patch.object(services.ServiceManager, 'save_ready') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the timestamp is seconds since epoch -- but it's timezone specific. This change was so this test would run successfully on all machines regardless of the locale's timezone. (ie -- it failed on my machine but was okay in other places where there was no TZ set)