mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # |
| 3 | # Copyright 2008 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | """Test for atest.""" |
| 6 | |
| 7 | import unittest, os, sys, tempfile, StringIO, urllib2 |
| 8 | |
| 9 | import common |
| 10 | from autotest_lib.cli import cli_mock, topic_common, rpc |
| 11 | from autotest_lib.frontend.afe.json_rpc import proxy |
| 12 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 13 | |
| 14 | class item_parse_info_unittest(cli_mock.cli_unittest): |
| 15 | def __test_parsing_flist_bad(self, options): |
| 16 | parse_info = topic_common.item_parse_info |
| 17 | test_parse_info = parse_info(attribute_name='testing', |
| 18 | filename_option='flist') |
| 19 | self.assertRaises(topic_common.CliError, |
| 20 | test_parse_info.get_values, options, []) |
| 21 | |
| 22 | |
| 23 | def __test_parsing_flist_good(self, options, expected): |
| 24 | parse_info = topic_common.item_parse_info |
| 25 | test_parse_info = parse_info(attribute_name='testing', |
| 26 | filename_option='flist') |
| 27 | result, leftover = test_parse_info.get_values(options, []) |
| 28 | |
| 29 | self.assertEqualNoOrder(expected, result) |
| 30 | os.unlink(options.flist) |
| 31 | |
| 32 | |
| 33 | def __test_parsing_inline_good(self, options, expected): |
| 34 | parse_info = topic_common.item_parse_info |
| 35 | test_parse_info = parse_info(attribute_name='testing', |
| 36 | inline_option='inline') |
| 37 | result, leftover = test_parse_info.get_values(options, []) |
| 38 | |
| 39 | self.assertEqualNoOrder(expected, result) |
| 40 | |
| 41 | |
| 42 | def __test_parsing_leftover_good(self, leftover, expected): |
| 43 | class opt(object): |
| 44 | pass |
| 45 | parse_info = topic_common.item_parse_info |
| 46 | test_parse_info = parse_info(attribute_name='testing', |
| 47 | inline_option='inline', |
| 48 | use_leftover=True) |
| 49 | result, leftover = test_parse_info.get_values(opt(), leftover) |
| 50 | |
| 51 | self.assertEqualNoOrder(expected, result) |
| 52 | |
| 53 | |
| 54 | def __test_parsing_all_good(self, options, leftover, expected): |
| 55 | parse_info = topic_common.item_parse_info |
| 56 | test_parse_info = parse_info(attribute_name='testing', |
| 57 | inline_option='inline', |
| 58 | filename_option='flist', |
| 59 | use_leftover=True) |
| 60 | result, leftover = test_parse_info.get_values(options, leftover) |
| 61 | |
| 62 | self.assertEqualNoOrder(expected, result) |
| 63 | os.unlink(options.flist) |
| 64 | |
| 65 | |
| 66 | def __test_parsing_all_bad(self, options, leftover): |
| 67 | parse_info = topic_common.item_parse_info |
| 68 | test_parse_info = parse_info(attribute_name='testing', |
| 69 | inline_option='inline', |
| 70 | filename_option='flist', |
| 71 | use_leftover=True) |
| 72 | self.assertRaises(topic_common.CliError, |
| 73 | test_parse_info.get_values, options, leftover) |
| 74 | |
| 75 | |
| 76 | def test_file_list_wrong_file(self): |
| 77 | class opt(object): |
| 78 | flist = './does_not_exist' |
| 79 | self.__test_parsing_flist_bad(opt()) |
| 80 | |
| 81 | |
| 82 | def test_file_list_empty_file(self): |
| 83 | class opt(object): |
| 84 | flist = cli_mock.create_file('') |
| 85 | self.__test_parsing_flist_bad(opt()) |
| 86 | |
| 87 | |
| 88 | def test_file_list_ok(self): |
| 89 | class opt(object): |
| 90 | flist = cli_mock.create_file('a\nb\nc\n') |
| 91 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c']) |
| 92 | |
| 93 | |
| 94 | def test_file_list_one_line_space(self): |
| 95 | class opt(object): |
| 96 | flist = cli_mock.create_file('a b c\nd e\nf\n') |
| 97 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e', 'f']) |
| 98 | |
| 99 | |
| 100 | def test_file_list_one_line_comma(self): |
| 101 | class opt(object): |
| 102 | flist = cli_mock.create_file('a,b,c\nd,e\nf\n') |
| 103 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e', 'f']) |
| 104 | |
| 105 | |
| 106 | def test_file_list_one_line_mix(self): |
| 107 | class opt(object): |
| 108 | flist = cli_mock.create_file('a,b c\nd,e\nf\ng h,i') |
| 109 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e', |
| 110 | 'f', 'g', 'h', 'i']) |
| 111 | |
| 112 | |
| 113 | def test_file_list_one_line_comma_space(self): |
| 114 | class opt(object): |
| 115 | flist = cli_mock.create_file('a, b c\nd,e\nf\ng h,i') |
| 116 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e', |
| 117 | 'f', 'g', 'h', 'i']) |
| 118 | |
| 119 | |
| 120 | def test_file_list_line_end_comma_space(self): |
| 121 | class opt(object): |
| 122 | flist = cli_mock.create_file('a, b c\nd,e, \nf,\ng h,i ,') |
| 123 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e', |
| 124 | 'f', 'g', 'h', 'i']) |
| 125 | |
| 126 | |
| 127 | def test_file_list_no_eof(self): |
| 128 | class opt(object): |
| 129 | flist = cli_mock.create_file('a\nb\nc') |
| 130 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c']) |
| 131 | |
| 132 | |
| 133 | def test_file_list_blank_line(self): |
| 134 | class opt(object): |
| 135 | flist = cli_mock.create_file('\na\nb\n\nc\n') |
| 136 | self.__test_parsing_flist_good(opt(), ['a', 'b', 'c']) |
| 137 | |
| 138 | |
| 139 | def test_file_list_opt_list_one(self): |
| 140 | class opt(object): |
| 141 | inline = 'a' |
| 142 | self.__test_parsing_inline_good(opt(), ['a']) |
| 143 | |
| 144 | |
| 145 | def test_file_list_opt_list_space(self): |
| 146 | class opt(object): |
| 147 | inline = 'a b c' |
| 148 | self.__test_parsing_inline_good(opt(), ['a', 'b', 'c']) |
| 149 | |
| 150 | |
| 151 | def test_file_list_opt_list_mix_space_comma(self): |
| 152 | class opt(object): |
| 153 | inline = 'a b,c,d e' |
| 154 | self.__test_parsing_inline_good(opt(), ['a', 'b', 'c', 'd', 'e']) |
| 155 | |
| 156 | |
| 157 | def test_file_list_opt_list_mix_comma_space(self): |
| 158 | class opt(object): |
| 159 | inline = 'a b,c, d e' |
| 160 | self.__test_parsing_inline_good(opt(), ['a', 'b', 'c', 'd', 'e']) |
| 161 | |
| 162 | |
| 163 | def test_file_list_opt_list_end_comma_space(self): |
| 164 | class opt(object): |
| 165 | inline = 'a b, ,c,, d e, ' |
| 166 | self.__test_parsing_inline_good(opt(), ['a', 'b', 'c', 'd', 'e']) |
| 167 | |
| 168 | |
| 169 | def test_file_list_add_on_space(self): |
| 170 | self.__test_parsing_leftover_good(['a','c','b'], |
| 171 | ['a', 'b', 'c']) |
| 172 | |
| 173 | |
| 174 | def test_file_list_add_on_mix_space_comma(self): |
| 175 | self.__test_parsing_leftover_good(['a', 'c','b,d'], |
| 176 | ['a', 'b', 'c', 'd']) |
| 177 | |
| 178 | |
| 179 | def test_file_list_add_on_mix_comma_space(self): |
| 180 | self.__test_parsing_leftover_good(['a', 'c', 'b,', 'd'], |
| 181 | ['a', 'b', 'c', 'd']) |
| 182 | |
| 183 | |
| 184 | def test_file_list_add_on_end_comma_space(self): |
| 185 | self.__test_parsing_leftover_good(['a', 'c', 'b,', 'd,', ','], |
| 186 | ['a', 'b', 'c', 'd']) |
| 187 | |
| 188 | |
| 189 | def test_file_list_all_opt(self): |
| 190 | class opt(object): |
| 191 | flist = cli_mock.create_file('f\ng\nh\n') |
| 192 | inline = 'a b,c,d e' |
| 193 | self.__test_parsing_all_good(opt(), ['i', 'j'], |
| 194 | ['a', 'b', 'c', 'd', 'e', |
| 195 | 'f', 'g', 'h', 'i', 'j']) |
| 196 | |
| 197 | |
| 198 | def test_file_list_all_opt_empty_file(self): |
| 199 | class opt(object): |
| 200 | flist = cli_mock.create_file('') |
| 201 | inline = 'a b,c,d e' |
| 202 | self.__test_parsing_all_bad(opt(), ['i', 'j']) |
| 203 | |
| 204 | |
| 205 | def test_file_list_all_opt_in_common(self): |
| 206 | class opt(object): |
| 207 | flist = cli_mock.create_file('f\nc\na\n') |
| 208 | inline = 'a b,c,d e' |
| 209 | self.__test_parsing_all_good(opt(), ['i','j,d'], |
| 210 | ['a', 'b', 'c', 'd', 'e', 'f', 'i', 'j']) |
| 211 | |
| 212 | |
| 213 | def test_file_list_all_opt_in_common_space(self): |
| 214 | class opt(object): |
| 215 | flist = cli_mock.create_file('a b c\nd,e\nf\ng') |
| 216 | inline = 'a b,c,d h' |
| 217 | self.__test_parsing_all_good(opt(), ['i','j,d'], |
| 218 | ['a', 'b', 'c', 'd', 'e', |
| 219 | 'f', 'g', 'h', 'i', 'j']) |
| 220 | |
| 221 | |
| 222 | def test_file_list_all_opt_in_common_weird(self): |
| 223 | class opt(object): |
| 224 | flist = cli_mock.create_file('a b c\nd,e\nf\ng, \n, ,,') |
| 225 | inline = 'a b,c,d h, , ,, ' |
| 226 | self.__test_parsing_all_good(opt(), ['i','j,d'], |
| 227 | ['a', 'b', 'c', 'd', 'e', |
| 228 | 'f', 'g', 'h', 'i', 'j']) |
| 229 | |
| 230 | |
| 231 | class atest_unittest(cli_mock.cli_unittest): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 232 | def setUp(self): |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 233 | super(atest_unittest, self).setUp() |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 234 | self.atest = topic_common.atest() |
| 235 | self.atest.afe = rpc.afe_comm() |
| 236 | if 'AUTOTEST_WEB' in os.environ: |
| 237 | del os.environ['AUTOTEST_WEB'] |
| 238 | |
| 239 | |
| 240 | def tearDown(self): |
| 241 | self.atest = None |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 242 | super(atest_unittest, self).tearDown() |
mbligh | f173334 | 2008-09-04 16:45:46 +0000 | [diff] [blame] | 243 | |
| 244 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 245 | def test_invalid_arg_kill(self): |
| 246 | self.atest.kill_on_failure = True |
| 247 | self.god.mock_io() |
| 248 | sys.exit.expect_call(1).and_raises(cli_mock.ExitException) |
| 249 | self.assertRaises(cli_mock.ExitException, |
| 250 | self.atest.invalid_arg, 'This is bad') |
| 251 | (output, err) = self.god.unmock_io() |
| 252 | self.god.check_playback() |
| 253 | self.assert_(err.find('This is bad') >= 0) |
| 254 | |
| 255 | |
| 256 | def test_invalid_arg_continue(self): |
| 257 | self.god.mock_io() |
| 258 | self.atest.invalid_arg('This is sort of ok') |
| 259 | (output, err) = self.god.unmock_io() |
| 260 | self.assert_(err.find('This is sort of ok') >= 0) |
| 261 | |
| 262 | |
| 263 | def test_failure_continue(self): |
| 264 | self.atest.failure('This is partly bad', item='item0', |
| 265 | what_failed='something important') |
| 266 | err = self.atest.failed['something important'] |
| 267 | self.assert_('This is partly bad' in err.keys()) |
| 268 | |
| 269 | |
| 270 | def test_failure_continue_multiple_different_errors(self): |
| 271 | self.atest.failure('This is partly bad', item='item0', |
| 272 | what_failed='something important') |
| 273 | self.atest.failure('This is really bad', item='item0', |
| 274 | what_failed='something really important') |
| 275 | err = self.atest.failed['something important'] |
| 276 | self.assert_('This is partly bad' in err) |
| 277 | self.assert_('This is really bad' not in err) |
| 278 | err = self.atest.failed['something really important'] |
| 279 | self.assert_('This is partly bad' not in err) |
| 280 | self.assert_('This is really bad' in err) |
| 281 | |
| 282 | |
| 283 | def test_failure_continue_multiple_same_errors(self): |
| 284 | self.atest.failure('This is partly bad', item='item0', |
| 285 | what_failed='something important') |
| 286 | self.atest.failure('This is really bad', item='item1', |
| 287 | what_failed='something important') |
| 288 | errs = self.atest.failed['something important'] |
| 289 | self.assert_('This is partly bad' in errs) |
| 290 | self.assert_('This is really bad' in errs) |
| 291 | self.assert_(set(['item0']) in errs.values()) |
| 292 | self.assert_(set(['item1']) in errs.values()) |
| 293 | |
| 294 | |
| 295 | def test_failure_continue_multiple_errors_mixed(self): |
| 296 | self.atest.failure('This is partly bad', item='item0', |
| 297 | what_failed='something important') |
| 298 | self.atest.failure('This is really bad', item='item0', |
| 299 | what_failed='something really important') |
| 300 | self.atest.failure('This is really bad', item='item1', |
| 301 | what_failed='something important') |
| 302 | errs = self.atest.failed['something important'] |
| 303 | self.assert_('This is partly bad' in errs) |
| 304 | self.assert_('This is really bad' in errs) |
| 305 | self.assert_(set(['item0']) in errs.values()) |
| 306 | self.assert_(set(['item1']) in errs.values()) |
| 307 | |
| 308 | errs = self.atest.failed['something really important'] |
| 309 | self.assert_('This is really bad' in errs) |
| 310 | self.assert_('This is partly bad' not in errs) |
| 311 | self.assert_(set(['item0']) in errs.values()) |
| 312 | self.assert_(set(['item1']) not in errs.values()) |
| 313 | |
| 314 | |
| 315 | def test_failure_continue_multiple_errors_mixed_same_error(self): |
| 316 | self.atest.failure('This is partly bad', item='item0', |
| 317 | what_failed='something important') |
| 318 | self.atest.failure('This is really bad', item='item0', |
| 319 | what_failed='something really important') |
| 320 | self.atest.failure('This is partly bad', item='item1', |
| 321 | what_failed='something important') |
| 322 | errs = self.atest.failed['something important'] |
| 323 | self.assert_('This is partly bad' in errs) |
| 324 | self.assert_('This is really bad' not in errs) |
| 325 | self.assert_(set(['item0', 'item1']) in errs.values()) |
| 326 | |
| 327 | errs = self.atest.failed['something really important'] |
| 328 | self.assert_('This is really bad' in errs) |
| 329 | self.assert_('This is partly bad' not in errs) |
| 330 | self.assert_(set(['item0']) in errs.values()) |
| 331 | self.assert_(set(['item1']) not in errs.values()) |
| 332 | |
| 333 | |
| 334 | def test_failure_exit(self): |
| 335 | self.atest.kill_on_failure = True |
| 336 | self.god.mock_io() |
| 337 | sys.exit.expect_call(1).and_raises(cli_mock.ExitException) |
| 338 | self.assertRaises(cli_mock.ExitException, |
| 339 | self.atest.failure, 'This is partly bad') |
| 340 | (output, err) = self.god.unmock_io() |
| 341 | self.god.check_playback() |
| 342 | self.assert_(err.find('This is partly bad') >= 0) |
| 343 | |
| 344 | |
| 345 | def test_failure_exit_item(self): |
| 346 | self.atest.kill_on_failure = True |
| 347 | self.god.mock_io() |
| 348 | sys.exit.expect_call(1).and_raises(cli_mock.ExitException) |
| 349 | self.assertRaises(cli_mock.ExitException, |
| 350 | self.atest.failure, 'This is partly bad', |
| 351 | item='item0') |
| 352 | (output, err) = self.god.unmock_io() |
| 353 | self.god.check_playback() |
| 354 | self.assertWords(err, ['This is partly bad'], ['item0']) |
| 355 | |
| 356 | |
| 357 | def test_show_all_failures_common(self): |
| 358 | self.atest.failure('This is partly bad', item='item0', |
| 359 | what_failed='something important') |
| 360 | self.atest.failure('This is partly bad', item='item1', |
| 361 | what_failed='something important') |
| 362 | self.god.mock_io() |
| 363 | self.atest.show_all_failures() |
| 364 | (output, err) = self.god.unmock_io() |
| 365 | self.assertWords(err, ['something important', |
| 366 | 'This is partly bad', 'item0', 'item1']) |
| 367 | |
| 368 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 369 | def test_parse_add_on(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 370 | flist = cli_mock.create_file('host1\nhost2\nleft2') |
| 371 | sys.argv = ['atest', '--web', 'fooweb', '--parse', |
| 372 | '--kill-on-failure', 'left1', 'left2', '-M', flist] |
| 373 | self.atest.parser.add_option('-M', '--mlist', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 374 | item_info = topic_common.item_parse_info(attribute_name='hosts', |
| 375 | filename_option='mlist', |
| 376 | use_leftover=True) |
| 377 | (options, leftover) = self.atest.parse([item_info]) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 378 | self.assertEqualNoOrder(self.atest.hosts, |
| 379 | ['left1', 'left2', 'host1', 'host2']) |
| 380 | |
| 381 | self.assertEqual({'mlist': flist, |
| 382 | 'web_server': 'fooweb', |
| 383 | 'parse': True, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 384 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 385 | 'kill_on_failure': True, |
| 386 | 'verbose': False, |
| 387 | 'debug': False}, options) |
| 388 | self.assertEqual(leftover, []) |
| 389 | |
| 390 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 391 | def test_parse_no_add_on(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 392 | flist = cli_mock.create_file('host1\nhost2\nleft2') |
| 393 | sys.argv = ['atest', '--web', 'fooweb', '--parse', '-g', |
| 394 | '--kill-on-failure', 'left1', 'left2', '-M', flist] |
| 395 | self.atest.parser.add_option('-M', '--mlist', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 396 | item_info = topic_common.item_parse_info(attribute_name='hosts', |
| 397 | filename_option='mlist') |
| 398 | (options, leftover) = self.atest.parse([item_info]) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 399 | self.assertEqualNoOrder(self.atest.hosts, |
| 400 | ['left2', 'host1', 'host2']) |
| 401 | |
| 402 | self.assertEqual({'mlist': flist, |
| 403 | 'web_server': 'fooweb', |
| 404 | 'parse': True, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 405 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 406 | 'kill_on_failure': True, |
| 407 | 'verbose': False, |
| 408 | 'debug': True}, options) |
| 409 | self.assertEqual(leftover, ['left1', 'left2']) |
| 410 | |
| 411 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 412 | def test_parse_add_on_first(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 413 | flist = cli_mock.create_file('host1\nhost2\nleft2') |
| 414 | ulist = cli_mock.create_file('user1\nuser2\nuser3\n') |
| 415 | sys.argv = ['atest', '-g', '--parse', '--ulist', ulist, |
| 416 | '-u', 'myuser,youruser', |
| 417 | '--kill-on-failure', 'left1', 'left2', '-M', flist] |
| 418 | self.atest.parser.add_option('-M', '--mlist', type='string') |
| 419 | self.atest.parser.add_option('-U', '--ulist', type='string') |
| 420 | self.atest.parser.add_option('-u', '--user', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 421 | host_info = topic_common.item_parse_info(attribute_name='hosts', |
| 422 | filename_option='mlist', |
| 423 | use_leftover=True) |
| 424 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 425 | inline_option='user', |
| 426 | filename_option='ulist') |
| 427 | |
| 428 | (options, leftover) = self.atest.parse([host_info, user_info]) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 429 | self.assertEqualNoOrder(self.atest.hosts, |
| 430 | ['left1', 'left2', 'host1', 'host2']) |
| 431 | self.assertEqualNoOrder(self.atest.users, |
| 432 | ['user1', 'user2', 'user3', |
| 433 | 'myuser', 'youruser']) |
| 434 | |
| 435 | self.assertEqual({'mlist': flist, |
| 436 | 'ulist': ulist, |
| 437 | 'user': 'myuser,youruser', |
| 438 | 'web_server': None, |
| 439 | 'parse': True, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 440 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 441 | 'kill_on_failure': True, |
| 442 | 'verbose': False, |
| 443 | 'debug': True}, options) |
| 444 | self.assertEqual(leftover, []) |
| 445 | |
| 446 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 447 | def test_parse_add_on_second(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 448 | flist = cli_mock.create_file('host1\nhost2\nleft2') |
| 449 | ulist = cli_mock.create_file('user1\nuser2\nuser3\n') |
| 450 | sys.argv = ['atest', '-g', '--parse', '-U', ulist, |
| 451 | '-u', 'myuser,youruser', |
| 452 | '--kill-on-failure', 'left1', 'left2', '-M', flist] |
| 453 | self.atest.parser.add_option('-M', '--mlist', type='string') |
| 454 | self.atest.parser.add_option('-U', '--ulist', type='string') |
| 455 | self.atest.parser.add_option('-u', '--user', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 456 | host_info = topic_common.item_parse_info(attribute_name='hosts', |
| 457 | filename_option='mlist', |
| 458 | use_leftover=True) |
| 459 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 460 | inline_option='user', |
| 461 | filename_option='ulist') |
| 462 | (options, leftover) = self.atest.parse([host_info, user_info]) |
| 463 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 464 | self.assertEqualNoOrder(self.atest.hosts, |
| 465 | ['left1', 'left2', 'host1', 'host2']) |
| 466 | self.assertEqualNoOrder(self.atest.users, |
| 467 | ['user1', 'user2', 'user3', |
| 468 | 'myuser', 'youruser']) |
| 469 | |
| 470 | self.assertEqual({'mlist': flist, |
| 471 | 'ulist': ulist, |
| 472 | 'user': 'myuser,youruser', |
| 473 | 'web_server': None, |
| 474 | 'parse': True, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 475 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 476 | 'kill_on_failure': True, |
| 477 | 'verbose': False, |
| 478 | 'debug': True}, options) |
| 479 | self.assertEqual(leftover, []) |
| 480 | |
| 481 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 482 | def test_parse_all_opts(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 483 | flist = cli_mock.create_file('host1\nhost2\nleft2') |
| 484 | ulist = cli_mock.create_file('user1\nuser2\nuser3\n') |
| 485 | sys.argv = ['atest', '-g', '--parse', '--ulist', ulist, |
| 486 | '-u', 'myuser,youruser', |
| 487 | '--kill-on-failure', '-M', flist, 'left1', 'left2'] |
| 488 | self.atest.parser.add_option('-M', '--mlist', type='string') |
| 489 | self.atest.parser.add_option('-U', '--ulist', type='string') |
| 490 | self.atest.parser.add_option('-u', '--user', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 491 | host_info = topic_common.item_parse_info(attribute_name='hosts', |
| 492 | filename_option='mlist', |
| 493 | use_leftover=True) |
| 494 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 495 | inline_option='user', |
| 496 | filename_option='ulist') |
| 497 | (options, leftover) = self.atest.parse([host_info, user_info]) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 498 | self.assertEqualNoOrder(self.atest.hosts, |
| 499 | ['left1', 'left2', 'host1', 'host2']) |
| 500 | self.assertEqualNoOrder(self.atest.users, |
| 501 | ['user1', 'user2', 'user3', |
| 502 | 'myuser', 'youruser']) |
| 503 | |
| 504 | self.assertEqual({'mlist': flist, |
| 505 | 'ulist': ulist, |
| 506 | 'user': 'myuser,youruser', |
| 507 | 'web_server': None, |
| 508 | 'parse': True, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 509 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 510 | 'kill_on_failure': True, |
| 511 | 'verbose': False, |
| 512 | 'debug': True}, options) |
| 513 | self.assertEqual(leftover, []) |
| 514 | |
| 515 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 516 | def test_parse_no_add_on(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 517 | flist = cli_mock.create_file('host1\nhost2\nleft2') |
| 518 | ulist = cli_mock.create_file('user1\nuser2\nuser3\n') |
| 519 | sys.argv = ['atest', '-U', ulist, |
| 520 | '--kill-on-failure', '-M', flist] |
| 521 | self.atest.parser.add_option('-M', '--mlist', type='string') |
| 522 | self.atest.parser.add_option('-U', '--ulist', type='string') |
| 523 | self.atest.parser.add_option('-u', '--user', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 524 | host_info = topic_common.item_parse_info(attribute_name='hosts', |
| 525 | filename_option='mlist', |
| 526 | use_leftover=True) |
| 527 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 528 | inline_option='user', |
| 529 | filename_option='ulist') |
| 530 | (options, leftover) = self.atest.parse([host_info, user_info]) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 531 | self.assertEqualNoOrder(self.atest.hosts, |
| 532 | ['left2', 'host1', 'host2']) |
| 533 | self.assertEqualNoOrder(self.atest.users, |
| 534 | ['user1', 'user2', 'user3']) |
| 535 | |
| 536 | self.assertEqual({'mlist': flist, |
| 537 | 'ulist': ulist, |
| 538 | 'user': None, |
| 539 | 'web_server': None, |
| 540 | 'parse': False, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 541 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 542 | 'kill_on_failure': True, |
| 543 | 'verbose': False, |
| 544 | 'debug': False}, options) |
| 545 | self.assertEqual(leftover, []) |
| 546 | |
| 547 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 548 | def test_parse_no_flist_add_on(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 549 | sys.argv = ['atest', '-g', '--parse', '-u', 'myuser,youruser', |
| 550 | '--kill-on-failure', 'left1', 'left2'] |
| 551 | self.atest.parser.add_option('-M', '--mlist', type='string') |
| 552 | self.atest.parser.add_option('-U', '--ulist', type='string') |
| 553 | self.atest.parser.add_option('-u', '--user', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 554 | host_info = topic_common.item_parse_info(attribute_name='hosts', |
| 555 | use_leftover=True) |
| 556 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 557 | inline_option='user') |
| 558 | (options, leftover) = self.atest.parse([host_info, user_info]) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 559 | self.assertEqualNoOrder(self.atest.hosts, |
| 560 | ['left1', 'left2']) |
| 561 | self.assertEqualNoOrder(self.atest.users, |
| 562 | ['myuser', 'youruser']) |
| 563 | |
| 564 | self.assertEqual({'mlist': None, |
| 565 | 'ulist': None, |
| 566 | 'user': 'myuser,youruser', |
| 567 | 'web_server': None, |
| 568 | 'parse': True, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 569 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 570 | 'kill_on_failure': True, |
| 571 | 'verbose': False, |
| 572 | 'debug': True}, options) |
| 573 | self.assertEqual(leftover, []) |
| 574 | |
| 575 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 576 | def test_parse_no_flist_no_add_on(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 577 | sys.argv = ['atest', '-u', 'myuser,youruser', '--kill-on-failure', |
| 578 | '-a', 'acl1,acl2'] |
| 579 | self.atest.parser.add_option('-u', '--user', type='string') |
| 580 | self.atest.parser.add_option('-a', '--acl', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 581 | acl_info = topic_common.item_parse_info(attribute_name='acls', |
| 582 | inline_option='acl') |
| 583 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 584 | inline_option='user') |
| 585 | (options, leftover) = self.atest.parse([user_info, acl_info]) |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 586 | self.assertEqualNoOrder(self.atest.acls, |
| 587 | ['acl1', 'acl2']) |
| 588 | self.assertEqualNoOrder(self.atest.users, |
| 589 | ['myuser', 'youruser']) |
| 590 | |
| 591 | self.assertEqual({'user': 'myuser,youruser', |
| 592 | 'acl': 'acl1,acl2', |
| 593 | 'web_server': None, |
| 594 | 'parse': False, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 595 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 596 | 'kill_on_failure': True, |
| 597 | 'verbose': False, |
| 598 | 'debug': False}, options) |
| 599 | self.assertEqual(leftover, []) |
| 600 | |
| 601 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 602 | def test_parse_req_items_ok(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 603 | sys.argv = ['atest', '-u', 'myuser,youruser'] |
| 604 | self.atest.parser.add_option('-u', '--user', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 605 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 606 | inline_option='user') |
| 607 | (options, leftover) = self.atest.parse([user_info], |
| 608 | req_items='users') |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 609 | self.assertEqualNoOrder(self.atest.users, |
| 610 | ['myuser', 'youruser']) |
| 611 | |
| 612 | self.assertEqual({'user': 'myuser,youruser', |
| 613 | 'web_server': None, |
| 614 | 'parse': False, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 615 | 'parse_delim': '|', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 616 | 'kill_on_failure': False, |
| 617 | 'verbose': False, |
| 618 | 'debug': False}, options) |
| 619 | self.assertEqual(leftover, []) |
| 620 | |
| 621 | |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 622 | def test_parse_req_items_missing(self): |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 623 | sys.argv = ['atest', '-u', 'myuser,youruser', '--kill-on-failure'] |
| 624 | self.atest.parser.add_option('-u', '--user', type='string') |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 625 | acl_info = topic_common.item_parse_info(attribute_name='acls', |
| 626 | inline_option='acl') |
| 627 | user_info = topic_common.item_parse_info(attribute_name='users', |
| 628 | inline_option='user') |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 629 | self.god.mock_io() |
| 630 | sys.exit.expect_call(1).and_raises(cli_mock.ExitException) |
| 631 | self.assertRaises(cli_mock.ExitException, |
mbligh | 9deeefa | 2009-05-01 23:11:08 +0000 | [diff] [blame] | 632 | self.atest.parse, |
| 633 | [user_info, acl_info], |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 634 | 'acls') |
| 635 | self.assertEqualNoOrder(self.atest.users, |
| 636 | ['myuser', 'youruser']) |
| 637 | |
| 638 | self.assertEqualNoOrder(self.atest.acls, []) |
| 639 | self.god.check_playback() |
| 640 | self.god.unmock_io() |
| 641 | |
| 642 | |
| 643 | def test_parse_bad_option(self): |
| 644 | sys.argv = ['atest', '--unknown'] |
| 645 | self.god.stub_function(self.atest.parser, 'error') |
| 646 | self.atest.parser.error.expect_call('no such option: --unknown').and_return(None) |
| 647 | self.atest.parse() |
| 648 | self.god.check_playback() |
| 649 | |
| 650 | |
| 651 | def test_parse_all_set(self): |
| 652 | sys.argv = ['atest', '--web', 'fooweb', '--parse', '--debug', |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 653 | '--kill-on-failure', '--verbose', 'left1', 'left2', |
| 654 | '--parse-delim', '?'] |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 655 | (options, leftover) = self.atest.parse() |
| 656 | self.assertEqual({'web_server': 'fooweb', |
| 657 | 'parse': True, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 658 | 'parse_delim': '?', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 659 | 'kill_on_failure': True, |
| 660 | 'verbose': True, |
| 661 | 'debug': True}, options) |
| 662 | self.assertEqual(leftover, ['left1', 'left2']) |
| 663 | |
| 664 | |
| 665 | def test_execute_rpc_bad_server(self): |
| 666 | self.atest.afe = rpc.afe_comm('http://does_not_exist') |
| 667 | self.god.mock_io() |
| 668 | rpc.afe_comm.run.expect_call('myop').and_raises(urllib2.URLError("<urlopen error (-2, 'Name or service not known')>")) |
| 669 | sys.exit.expect_call(1).and_raises(cli_mock.ExitException) |
| 670 | self.assertRaises(cli_mock.ExitException, |
| 671 | self.atest.execute_rpc, 'myop') |
| 672 | (output, err) = self.god.unmock_io() |
| 673 | self.god.check_playback() |
| 674 | self.assert_(err.find('http://does_not_exist') >= 0) |
| 675 | |
| 676 | |
| 677 | # |
| 678 | # Print Unit tests |
| 679 | # |
| 680 | def __test_print_fields(self, func, expected, **dargs): |
| 681 | if not dargs.has_key('items'): |
| 682 | dargs['items']=[{'hostname': 'h0', |
| 683 | 'platform': 'p0', |
| 684 | 'labels': [u'l0', u'l1'], |
| 685 | 'locked': 1, |
| 686 | 'id': 'id0', |
| 687 | 'name': 'name0'}, |
| 688 | {'hostname': 'h1', |
| 689 | 'platform': 'p1', |
| 690 | 'labels': [u'l2', u'l3'], |
| 691 | 'locked': 0, |
| 692 | 'id': 'id1', |
| 693 | 'name': 'name1'}] |
| 694 | self.god.mock_io() |
| 695 | func(**dargs) |
| 696 | (output, err) = self.god.unmock_io() |
| 697 | self.assertEqual(expected, output) |
| 698 | |
| 699 | |
| 700 | # |
| 701 | # Print fields Standard |
| 702 | # |
| 703 | def __test_print_fields_std(self, keys, expected): |
| 704 | self.__test_print_fields(self.atest.print_fields_std, |
| 705 | expected, keys=keys) |
| 706 | |
| 707 | |
| 708 | def test_print_fields_std_one_str(self): |
| 709 | self.__test_print_fields_std(['hostname'], |
| 710 | 'Host: h0\n' |
| 711 | 'Host: h1\n') |
| 712 | |
| 713 | |
| 714 | def test_print_fields_std_conv_bool(self): |
| 715 | """Make sure the conversion functions are called""" |
| 716 | self.__test_print_fields_std(['locked'], |
| 717 | 'Locked: True\n' |
| 718 | 'Locked: False\n') |
| 719 | |
| 720 | |
| 721 | def test_print_fields_std_conv_label(self): |
| 722 | """Make sure the conversion functions are called""" |
| 723 | self.__test_print_fields_std(['labels'], |
| 724 | 'Labels: l0, l1\n' |
| 725 | 'Labels: l2, l3\n') |
| 726 | |
| 727 | |
| 728 | def test_print_fields_std_all_fields(self): |
| 729 | """Make sure the conversion functions are called""" |
| 730 | self.__test_print_fields_std(['hostname', 'platform','locked'], |
| 731 | 'Host: h0\n' |
| 732 | 'Platform: p0\n' |
| 733 | 'Locked: True\n' |
| 734 | 'Host: h1\n' |
| 735 | 'Platform: p1\n' |
| 736 | 'Locked: False\n') |
| 737 | |
| 738 | |
| 739 | # |
| 740 | # Print fields parse |
| 741 | # |
| 742 | def __test_print_fields_parse(self, keys, expected): |
| 743 | self.__test_print_fields(self.atest.print_fields_parse, |
| 744 | expected, keys=keys) |
| 745 | |
| 746 | |
| 747 | def test_print_fields_parse_one_str(self): |
| 748 | self.__test_print_fields_parse(['hostname'], |
| 749 | 'Host=h0\n' |
| 750 | 'Host=h1\n') |
| 751 | |
| 752 | |
| 753 | def test_print_fields_parse_conv_bool(self): |
| 754 | self.__test_print_fields_parse(['locked'], |
| 755 | 'Locked=True\n' |
| 756 | 'Locked=False\n') |
| 757 | |
| 758 | |
| 759 | def test_print_fields_parse_conv_label(self): |
| 760 | self.__test_print_fields_parse(['labels'], |
| 761 | 'Labels=l0, l1\n' |
| 762 | 'Labels=l2, l3\n') |
| 763 | |
| 764 | |
| 765 | def test_print_fields_parse_all_fields(self): |
| 766 | self.__test_print_fields_parse(['hostname', 'platform', 'locked'], |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 767 | 'Host=h0|Platform=p0|' |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 768 | 'Locked=True\n' |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 769 | 'Host=h1|Platform=p1|' |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 770 | 'Locked=False\n') |
| 771 | |
| 772 | |
| 773 | # |
| 774 | # Print table standard |
| 775 | # |
| 776 | def __test_print_table_std(self, keys, expected): |
| 777 | self.__test_print_fields(self.atest.print_table_std, |
| 778 | expected, keys_header=keys) |
| 779 | |
| 780 | |
| 781 | def test_print_table_std_all_fields(self): |
| 782 | self.__test_print_table_std(['hostname', 'platform','locked'], |
| 783 | 'Host Platform Locked\n' |
| 784 | 'h0 p0 True\n' |
| 785 | 'h1 p1 False\n') |
| 786 | |
| 787 | # TODO JME - add long fields tests |
| 788 | |
| 789 | |
| 790 | # |
| 791 | # Print table parse |
| 792 | # |
| 793 | def __test_print_table_parse(self, keys, expected): |
| 794 | self.__test_print_fields(self.atest.print_table_parse, |
| 795 | expected, keys_header=keys) |
| 796 | |
| 797 | |
| 798 | def test_print_table_parse_all_fields(self): |
| 799 | self.__test_print_table_parse(['hostname', 'platform', |
| 800 | 'locked'], |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 801 | 'Host=h0|Platform=p0|Locked=True\n' |
| 802 | 'Host=h1|Platform=p1|Locked=False\n') |
| 803 | |
| 804 | |
| 805 | def test_print_table_parse_all_fields(self): |
| 806 | self.atest.parse_delim = '?' |
| 807 | self.__test_print_table_parse(['hostname', 'platform', |
| 808 | 'locked'], |
| 809 | 'Host=h0?Platform=p0?Locked=True\n' |
| 810 | 'Host=h1?Platform=p1?Locked=False\n') |
| 811 | |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 812 | |
| 813 | def test_print_table_parse_empty_fields(self): |
| 814 | self.__test_print_fields(self.atest.print_table_parse, |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 815 | 'Host=h0|Platform=p0\n' |
| 816 | 'Host=h1|Platform=p1|Labels=l2, l3\n', |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 817 | items=[{'hostname': 'h0', |
| 818 | 'platform': 'p0', |
| 819 | 'labels': [], |
| 820 | 'locked': 1, |
| 821 | 'id': 'id0', |
| 822 | 'name': 'name0'}, |
| 823 | {'hostname': 'h1', |
| 824 | 'platform': 'p1', |
| 825 | 'labels': [u'l2', u'l3'], |
| 826 | 'locked': 0, |
| 827 | 'id': 'id1', |
| 828 | 'name': 'name1'}], |
| 829 | keys_header=['hostname', 'platform', |
| 830 | 'labels']) |
| 831 | |
| 832 | |
| 833 | # |
| 834 | # Print mix table standard |
| 835 | # |
| 836 | def __test_print_mix_table_std(self, keys_header, sublist_keys, |
| 837 | expected): |
| 838 | self.__test_print_fields(self.atest.print_table_std, |
| 839 | expected, |
| 840 | keys_header=keys_header, |
| 841 | sublist_keys=sublist_keys) |
| 842 | |
| 843 | |
| 844 | def test_print_mix_table(self): |
| 845 | self.__test_print_mix_table_std(['name', 'hostname'], |
| 846 | ['hosts', 'users'], |
| 847 | 'Name Host\n' |
| 848 | 'name0 h0\n' |
| 849 | 'name1 h1\n') |
| 850 | |
| 851 | # TODO(jmeurin) Add actual test with sublist_keys. |
| 852 | |
| 853 | |
| 854 | |
| 855 | # |
| 856 | # Print by ID standard |
| 857 | # |
| 858 | def __test_print_by_ids_std(self, expected): |
| 859 | self.__test_print_fields(self.atest.print_by_ids_std, |
| 860 | expected) |
| 861 | |
| 862 | |
| 863 | def test_print_by_ids_std_all_fields(self): |
| 864 | self.__test_print_by_ids_std('Id Name\n' |
| 865 | 'id0 name0\n' |
| 866 | 'id1 name1\n') |
| 867 | |
| 868 | |
| 869 | # |
| 870 | # Print by ID parse |
| 871 | # |
| 872 | def __test_print_by_ids_parse(self, expected): |
| 873 | self.__test_print_fields(self.atest.print_by_ids_parse, |
| 874 | expected) |
| 875 | |
| 876 | |
| 877 | def test_print_by_ids_parse_all_fields(self): |
mbligh | 47dc4d2 | 2009-02-12 21:48:34 +0000 | [diff] [blame] | 878 | self.__test_print_by_ids_parse('Id=id0|Name=name0|' |
| 879 | 'Id=id1|Name=name1\n') |
mbligh | be630eb | 2008-08-01 16:41:48 +0000 | [diff] [blame] | 880 | |
| 881 | |
| 882 | if __name__ == '__main__': |
| 883 | unittest.main() |