blob: e990a423b28c13ef635eca8ef4a520a1b59444d0 [file] [log] [blame]
Gregory Nisbetac7f7f72019-09-10 16:25:20 -07001#!/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
9from __future__ import unicode_literals
10
11import unittest
12
13import common
14from autotest_lib.cli import skylab_rollback
15
16
17class 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
30if __name__ == "__main__":
31 unittest.main()