Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 1 | # Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Unit tests for cros_generate_update_payload.""" |
| 6 | |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 7 | from chromite.lib import cros_test_lib |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 8 | from chromite.lib import partial_mock |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 9 | from chromite.lib.paygen import paygen_payload_lib |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 10 | from chromite.scripts import cros_generate_update_payload |
| 11 | |
Mike Frysinger | 807d828 | 2022-04-28 22:45:17 -0400 | [diff] [blame] | 12 | |
Greg Edelston | a4c9b3b | 2020-01-07 17:51:13 -0700 | [diff] [blame] | 13 | pytestmark = cros_test_lib.pytestmark_inside_only |
| 14 | |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 15 | |
| 16 | class CrOSGenerateUpdatePayloadTest(cros_test_lib.MockTestCase): |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 17 | """Test correct arguments passed to delta_generator.""" |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 18 | |
| 19 | def testGenerateUpdatePayload(self): |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 20 | """Test correct arguments propagated to delta_generator call.""" |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 21 | |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 22 | paygen_mock = self.PatchObject(paygen_payload_lib, 'GenerateUpdatePayload') |
| 23 | |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 24 | cros_generate_update_payload.main([ |
Amin Hassani | f845b81 | 2020-03-17 14:57:00 -0700 | [diff] [blame] | 25 | '--tgt-image', 'foo-tgt-image', |
| 26 | '--src-image', 'foo-src-image', |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 27 | '--output', 'foo-output', |
Vyshu | bae1f04 | 2021-05-17 10:01:48 -0400 | [diff] [blame] | 28 | '--check', '--minios', |
Amin Hassani | f845b81 | 2020-03-17 14:57:00 -0700 | [diff] [blame] | 29 | '--private-key', 'foo-private-key', |
| 30 | '--work-dir', 'foo-work-dir', |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 31 | ]) |
| 32 | |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 33 | paygen_mock.assert_called_once_with( |
Amin Hassani | f845b81 | 2020-03-17 14:57:00 -0700 | [diff] [blame] | 34 | partial_mock.HasString('foo-tgt-image'), |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 35 | partial_mock.HasString('foo-output'), |
| 36 | src_image=partial_mock.HasString('foo-src-image'), |
| 37 | work_dir=partial_mock.HasString('foo-work-dir'), |
| 38 | private_key=partial_mock.HasString('foo-private-key'), |
Vyshu | bae1f04 | 2021-05-17 10:01:48 -0400 | [diff] [blame] | 39 | check=True, minios=True) |