4 # Copyright (C) 2008 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """Script for unittesting the cli module"""
28 from ganeti import constants
29 from ganeti import cli
30 from ganeti.errors import OpPrereqError
32 class TestParseTimespec(unittest.TestCase):
33 """Testing case for ParseTimespec"""
35 def testValidTimes(self):
36 """Test valid timespecs"""
43 ('1w', 60 * 60 * 24 * 7),
47 for value, expected_result in test_data:
48 self.failUnlessEqual(cli.ParseTimespec(value), expected_result)
50 def testInvalidTime(self):
51 """Test invalid timespecs"""
58 for value in test_data:
59 self.failUnlessRaises(OpPrereqError, cli.ParseTimespec, value)
62 if __name__ == '__main__':