diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2017-04-18 12:27:57 +0200 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2017-04-24 08:23:24 +0000 |
commit | 512b1e00ab9b75e46cc76af40c72cf239fa100e5 (patch) | |
tree | 533eeec1377dd0502725e57bad3225d2e82fd812 /tests/ga/test_update.py | |
parent | c6339c307f36f77a4198d6faf1275acdf371200b (diff) | |
parent | 0f537ddd741bfb333dbc01b994013a2b4e75d26f (diff) | |
download | vyos-walinuxagent-512b1e00ab9b75e46cc76af40c72cf239fa100e5.tar.gz vyos-walinuxagent-512b1e00ab9b75e46cc76af40c72cf239fa100e5.zip |
Import patches-applied version 2.2.9-0ubuntu1 to applied/ubuntu/zesty-proposed
Imported using git-ubuntu import.
Changelog parent: c6339c307f36f77a4198d6faf1275acdf371200b
Unapplied parent: 0f537ddd741bfb333dbc01b994013a2b4e75d26f
New changelog entries:
* New upstream release (LP: #1683521).
Diffstat (limited to 'tests/ga/test_update.py')
-rw-r--r-- | tests/ga/test_update.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/tests/ga/test_update.py b/tests/ga/test_update.py index 5277e59..e7a7af4 100644 --- a/tests/ga/test_update.py +++ b/tests/ga/test_update.py @@ -522,7 +522,8 @@ class TestGuestAgent(UpdateTestCase): self.assertFalse(os.path.isdir(self.agent_path)) mock_http_get.return_value = ResponseMock( - status=restutil.httpclient.SERVICE_UNAVAILABLE) + status=restutil.httpclient.SERVICE_UNAVAILABLE, + response="") ext_uri = 'ext_uri' host_uri = 'host_uri' @@ -1039,7 +1040,7 @@ class TestUpdate(UpdateTestCase): with patch('subprocess.Popen', return_value=mock_child) as mock_popen: with patch('time.time', side_effect=mock_time.time): - with patch('time.sleep', return_value=mock_time.sleep): + with patch('time.sleep', side_effect=mock_time.sleep): self.update_handler.run_latest() self.assertEqual(1, mock_popen.call_count) @@ -1082,7 +1083,22 @@ class TestUpdate(UpdateTestCase): self._test_run_latest(mock_child=mock_child, mock_time=mock_time) self.assertEqual(1, mock_child.poll.call_count) self.assertEqual(0, mock_child.wait.call_count) - self.assertEqual(2, mock_time.time_call_count) + return + + def test_run_latest_polls_frequently_if_installed_is_latest(self): + mock_child = ChildMock(return_value=0) + mock_time = TimeMock(time_increment=CHILD_HEALTH_INTERVAL/2) + self._test_run_latest(mock_time=mock_time) + self.assertEqual(1, mock_time.sleep_interval) + return + + def test_run_latest_polls_moderately_if_installed_not_latest(self): + self.prepare_agents() + + mock_child = ChildMock(return_value=0) + mock_time = TimeMock(time_increment=CHILD_HEALTH_INTERVAL/2) + self._test_run_latest(mock_time=mock_time) + self.assertNotEqual(1, mock_time.sleep_interval) return def test_run_latest_defaults_to_current(self): @@ -1137,7 +1153,6 @@ class TestUpdate(UpdateTestCase): return def test_run_latest_exception_blacklists(self): - # logger.add_logger_appender(logger.AppenderType.STDOUT) self.prepare_agents() latest_agent = self.update_handler.get_latest_agent() @@ -1371,9 +1386,10 @@ class ProtocolMock(object): class ResponseMock(Mock): - def __init__(self, status=restutil.httpclient.OK, response=None): + def __init__(self, status=restutil.httpclient.OK, response=None, reason=None): Mock.__init__(self) self.status = status + self.reason = reason self.response = response return @@ -1388,7 +1404,11 @@ class TimeMock(Mock): self.time_call_count = 0 self.time_increment = time_increment - self.sleep = Mock(return_value=0) + self.sleep_interval = None + return + + def sleep(self, n): + self.sleep_interval = n return def time(self): |