| Index: chrome/common/extensions/docs/server2/sidenav_data_source_test.py
|
| ===================================================================
|
| --- chrome/common/extensions/docs/server2/sidenav_data_source_test.py (revision 202781)
|
| +++ chrome/common/extensions/docs/server2/sidenav_data_source_test.py (working copy)
|
| @@ -3,6 +3,7 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import json
|
| import os
|
| import sys
|
| import unittest
|
| @@ -25,16 +26,25 @@
|
| if 'items' in item:
|
| self._CheckLevels(item['items'], level=level + 1)
|
|
|
| + def _ReadLocalFile(self, filename):
|
| + with open(os.path.join(sys.path[0],
|
| + 'test_data',
|
| + 'sidenav_data_source',
|
| + filename), 'r') as f:
|
| + return f.read()
|
| +
|
| def testLevels(self):
|
| sidenav_data_source = SidenavDataSource.Factory(self._compiled_fs_factory,
|
| - self._json_path).Create('')
|
| + self._json_path,
|
| + '').Create('')
|
| sidenav_json = sidenav_data_source.get('test')
|
| self._CheckLevels(sidenav_json)
|
|
|
| def testSelected(self):
|
| sidenav_data_source = SidenavDataSource.Factory(
|
| self._compiled_fs_factory,
|
| - self._json_path).Create('www.b.com')
|
| + self._json_path,
|
| + '').Create('www.b.com')
|
| sidenav_json = sidenav_data_source.get('test')
|
| # This will be prettier once JSON is loaded with an OrderedDict.
|
| for item in sidenav_json:
|
| @@ -47,5 +57,15 @@
|
| # If we didn't return already, we should fail.
|
| self.fail()
|
|
|
| + def testAbsolutePath(self):
|
| + sidenav_data_source = SidenavDataSource.Factory(
|
| + self._compiled_fs_factory,
|
| + self._json_path,
|
| + '/trunk').Create('absolute_path/test.html')
|
| + sidenav_json = sidenav_data_source.get('absolute_path')
|
| + self.assertEqual(
|
| + sidenav_json,
|
| + json.loads(self._ReadLocalFile('absolute_path_sidenav_expected.json')))
|
| +
|
| if __name__ == '__main__':
|
| unittest.main()
|
|
|