OLD | NEW |
| (Empty) |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 import os | |
5 import tempfile | |
6 import unittest | |
7 | |
8 from telemetry.page import page_set | |
9 | |
10 simple_archive_info = """ | |
11 { | |
12 "archives": { | |
13 "data_01.wpr": ["http://www.foo.com/"], | |
14 "data_02.wpr": ["http://www.bar.com/"] | |
15 } | |
16 } | |
17 """ | |
18 | |
19 simple_set = """ | |
20 {"description": "hello", | |
21 "archive_data_file": "%s", | |
22 "pages": [ | |
23 {"url": "http://www.foo.com/"}, | |
24 {"url": "http://www.bar.com/"} | |
25 ] | |
26 } | |
27 """ | |
28 | |
29 class TestPageSet(unittest.TestCase): | |
30 def testSimpleSet(self): | |
31 with tempfile.NamedTemporaryFile() as f: | |
32 f.write(simple_archive_info) | |
33 f.flush() | |
34 archive_data_file = f.name | |
35 | |
36 with tempfile.NamedTemporaryFile() as f2: | |
37 f2.write(simple_set % archive_data_file) | |
38 f2.flush() | |
39 ps = page_set.PageSet.FromFile(f2.name) | |
40 | |
41 self.assertEquals('hello', ps.description) | |
42 self.assertEquals(archive_data_file, ps.archive_data_file) | |
43 self.assertEquals(2, len(ps.pages)) | |
44 self.assertEquals('http://www.foo.com/', ps.pages[0].url) | |
45 self.assertEquals('http://www.bar.com/', ps.pages[1].url) | |
46 self.assertEquals('data_01.wpr', os.path.basename(ps.pages[0].archive_path)) | |
47 self.assertEquals('data_02.wpr', os.path.basename(ps.pages[1].archive_path)) | |
OLD | NEW |