2 # Copyright 2013 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 """Tests for resource_finder."""
11 import resource_finder
13 SRC_DIR = os.path.join(os.path.dirname(__file__), '../../../src')
16 class ResourceFinderTest(unittest.TestCase):
19 finder = resource_finder.ResourceFinder([SRC_DIR])
20 guid_module = module.Module('guid')
21 guid_module.load_and_parse(os.path.join(SRC_DIR, 'base', 'guid.js'))
22 filename, contents = finder.find_and_load_module(guid_module, 'base')
24 self.assertTrue(os.path.samefile(filename,
25 os.path.join(SRC_DIR, 'base.js')))
26 expected_contents = ''
27 with open(os.path.join(SRC_DIR, 'base.js')) as f:
28 expected_contents = f.read()
29 self.assertEquals(contents, expected_contents)
31 def test_dependency_in_subdir(self):
32 finder = resource_finder.ResourceFinder([SRC_DIR])
33 guid_module = module.Module('base.guid')
34 guid_module.load_and_parse(os.path.join(SRC_DIR, 'base', 'guid.js'))
35 filename, contents = finder.find_and_load_module(
36 guid_module, 'tracing.tracks.track')
40 self.assertTrue(os.path.samefile(filename, os.path.join(
41 SRC_DIR, 'tracing', 'tracks', 'track.js')))
42 expected_contents = ''
43 with open(os.path.join(SRC_DIR, 'tracing', 'tracks', 'track.js')) as f:
44 expected_contents = f.read()
45 self.assertEquals(contents, expected_contents)
48 if __name__ == '__main__':