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): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 17 | """Test correct arguments passed to delta_generator.""" |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 18 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 19 | def testGenerateUpdatePayload(self): |
| 20 | """Test correct arguments propagated to delta_generator call.""" |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 21 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 22 | paygen_mock = self.PatchObject( |
| 23 | paygen_payload_lib, "GenerateUpdatePayload" |
| 24 | ) |
Amin Hassani | 6bc73a1 | 2018-11-29 21:07:12 -0800 | [diff] [blame] | 25 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 26 | cros_generate_update_payload.main( |
| 27 | [ |
| 28 | "--tgt-image", |
| 29 | "foo-tgt-image", |
| 30 | "--src-image", |
| 31 | "foo-src-image", |
| 32 | "--output", |
| 33 | "foo-output", |
| 34 | "--check", |
| 35 | "--minios", |
| 36 | "--private-key", |
| 37 | "foo-private-key", |
| 38 | "--work-dir", |
| 39 | "foo-work-dir", |
| 40 | ] |
| 41 | ) |
Tudor Brindus | 3e03eba | 2018-07-18 11:27:13 -0700 | [diff] [blame] | 42 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 43 | paygen_mock.assert_called_once_with( |
| 44 | partial_mock.HasString("foo-tgt-image"), |
| 45 | partial_mock.HasString("foo-output"), |
| 46 | src_image=partial_mock.HasString("foo-src-image"), |
| 47 | work_dir=partial_mock.HasString("foo-work-dir"), |
| 48 | private_key=partial_mock.HasString("foo-private-key"), |
| 49 | check=True, |
| 50 | minios=True, |
| 51 | ) |