-
Notifications
You must be signed in to change notification settings - Fork 372
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
Updated tests in test_update.py to use mock_update_handler #2552
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2552 +/- ##
===========================================
+ Coverage 71.79% 71.84% +0.05%
===========================================
Files 102 102
Lines 15321 15321
Branches 2429 2429
===========================================
+ Hits 11000 11008 +8
+ Misses 3829 3822 -7
+ Partials 492 491 -1
Continue to review full report at Codecov.
|
@@ -25,17 +25,29 @@ | |||
|
|||
|
|||
@contextlib.contextmanager | |||
def mock_update_handler(protocol, iterations=1, on_new_iteration=lambda _: None, exthandlers_handler=None, remote_access_handler=None, enable_agent_updates=False): | |||
def mock_update_handler(protocol, |
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.
Added new parameters to the mock in order to support more test scenarios
@@ -1294,77 +1294,6 @@ def test_get_latest_agent_should_return_latest_agent_even_on_bad_error_json(self | |||
latest_agent = self.update_handler.get_latest_agent_greater_than_daemon() | |||
self.assertEqual(latest_agent.version, dst_ver, "Latest agent version is invalid") | |||
|
|||
def _test_run(self, invocations=1, calls=1, enable_updates=False, sleep_interval=(6,)): |
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.
Moved those tests to a new class UpdateHandlerRunTestCase and updated them to use mock_update_handler
self.assertEqual(0, update_handler.get_iterations_completed()) | ||
|
||
def test_run_clears_sentinel_on_successful_exit(self): | ||
update_handler = self._test_run() |
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.
Should we create the sentinel file before starting the run? Doesn't look like this test is explicitly guaranteeing that run
clears the sentinel file, just that it doesn't create one on a successful termination.
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 only intention of this PR is to migrate those tests to use the mock_update_handler. no other improvements (and these tests need quite a few) were made
Updated the tests in TestUpdate to use mock_update_handler.
mock_update_handler does not start the background threads by default (these threads tend to produce random failures in the unit test runs)