OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import os | 6 import os |
7 import unittest | 7 import unittest |
8 | 8 |
9 from telemetry.core import discover | 9 from telemetry.core import discover |
10 from telemetry.page import page_set as page_set_module | 10 from telemetry.page import page_set as page_set_module |
11 from telemetry.page import page_set_archive_info | 11 from telemetry.page import page_set_archive_info |
12 | 12 |
13 | 13 |
14 class PageSetUnitTest(unittest.TestCase): | 14 class PageSetUnitTest(unittest.TestCase): |
15 | 15 |
16 def testSmoke(self): | 16 def testSmoke(self): |
17 # Instantiate all page sets and verify that all URLs have an associated | 17 # Instantiate all page sets and verify that all URLs have an associated |
18 # archive. | 18 # archive. |
19 page_sets_dir = os.path.dirname(__file__) | 19 page_sets_dir = os.path.dirname(__file__) |
20 page_sets = discover.GetAllPageSetFilenames(page_sets_dir) | 20 page_sets = discover.GetAllPageSetFilenames(page_sets_dir) |
21 for path in page_sets: | 21 for path in page_sets: |
22 page_set = page_set_module.PageSet.FromFile(path, ignore_archive=True) | 22 page_set = page_set_module.PageSet.FromFile(path) |
23 | 23 |
24 # TODO: Eventually these should be fatal. | 24 # TODO: Eventually these should be fatal. |
25 if not page_set.archive_data_file: | 25 if not page_set.archive_data_file: |
26 logging.warning('Skipping %s: missing archive data file', path) | 26 logging.warning('Skipping %s: missing archive data file', path) |
27 continue | 27 continue |
28 if not os.path.exists(os.path.join(page_sets_dir, | 28 if not os.path.exists(os.path.join(page_sets_dir, |
29 page_set.archive_data_file)): | 29 page_set.archive_data_file)): |
30 logging.warning('Skipping %s: archive data file not found', path) | 30 logging.warning('Skipping %s: archive data file not found', path) |
31 continue | 31 continue |
32 | 32 |
33 wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile( | 33 wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile( |
34 os.path.join(page_sets_dir, page_set.archive_data_file), | 34 os.path.join(page_sets_dir, page_set.archive_data_file), |
35 ignore_archive=True) | 35 ignore_archive=True) |
36 | 36 |
37 logging.info('Testing %s', path) | 37 logging.info('Testing %s', path) |
38 for page in page_set.pages: | 38 for page in page_set.pages: |
39 if not page.url.startswith('http'): | 39 if not page.url.startswith('http'): |
40 continue | 40 continue |
41 self.assertTrue(wpr_archive_info.WprFilePathForPage(page), | 41 self.assertTrue(wpr_archive_info.WprFilePathForPage(page), |
42 msg='No archive found for %s in %s' % ( | 42 msg='No archive found for %s in %s' % ( |
43 page.url, page_set.archive_data_file)) | 43 page.url, page_set.archive_data_file)) |
OLD | NEW |