OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import json |
| 7 import logging |
| 8 import sys |
| 9 import unittest |
| 10 |
| 11 import run_test_from_archive |
| 12 |
| 13 |
| 14 class RunTestFromArchiveTest(unittest.TestCase): |
| 15 def test_load_manifest_empty(self): |
| 16 m = run_test_from_archive.load_manifest('{}') |
| 17 self.assertEquals({}, m) |
| 18 |
| 19 def test_load_manifest_good(self): |
| 20 data = { |
| 21 u'command': [u'foo', u'bar'], |
| 22 u'files': { |
| 23 u'a': { |
| 24 u'link': u'somewhere', |
| 25 u'mode': 123, |
| 26 u'timestamp': 456, |
| 27 }, |
| 28 u'b': { |
| 29 u'mode': 123, |
| 30 u'sha-1': u'0123456789abcdef0123456789abcdef01234567' |
| 31 } |
| 32 }, |
| 33 u'read_only': False, |
| 34 u'relative_cwd': u'somewhere_else' |
| 35 } |
| 36 m = run_test_from_archive.load_manifest(json.dumps(data)) |
| 37 self.assertEquals(data, m) |
| 38 |
| 39 def test_load_manifest_bad(self): |
| 40 data = { |
| 41 u'files': { |
| 42 u'a': { |
| 43 u'link': u'somewhere', |
| 44 u'sha-1': u'0123456789abcdef0123456789abcdef01234567' |
| 45 } |
| 46 }, |
| 47 } |
| 48 try: |
| 49 run_test_from_archive.load_manifest(json.dumps(data)) |
| 50 self.fail() |
| 51 except run_test_from_archive.ConfigError: |
| 52 pass |
| 53 |
| 54 |
| 55 |
| 56 if __name__ == '__main__': |
| 57 logging.basicConfig( |
| 58 level=(logging.DEBUG if '-v' in sys.argv else logging.ERROR)) |
| 59 unittest.main() |
OLD | NEW |