Gregory Nisbet | ac7f7f7 | 2019-09-10 16:25:20 -0700 | [diff] [blame] | 1 | #!/usr/bin/python2 |
| 2 | # pylint: disable-msg=C0111 |
| 3 | # |
| 4 | # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file |
| 7 | """Test for skylab json utils.""" |
| 8 | |
| 9 | from __future__ import unicode_literals |
| 10 | |
| 11 | import unittest |
| 12 | |
| 13 | import common |
| 14 | from autotest_lib.cli import skylab_rollback |
| 15 | |
| 16 | |
| 17 | class skylab_rollback_unittest(unittest.TestCase): |
| 18 | def test_batches(self): |
| 19 | xs = list(range(40)) |
| 20 | expected = [list(range(20)), list(range(20, 40))] |
| 21 | actual = list(skylab_rollback._batches(xs, batch_size=20)) |
| 22 | self.assertEqual(expected, actual) |
| 23 | |
| 24 | def test_rollback(self): |
| 25 | actual = skylab_rollback.rollback(["a", "b"], dry_run=True) |
| 26 | expected = [["bash", "-c", skylab_rollback.ROLLBACK_CMD, "bash", "a", "b"]] |
| 27 | self.assertEqual(expected, actual) |
| 28 | |
| 29 | |
| 30 | if __name__ == "__main__": |
| 31 | unittest.main() |