| Index: chrome/common/extensions/docs/server2/rietveld_patcher_test.py
|
| ===================================================================
|
| --- chrome/common/extensions/docs/server2/rietveld_patcher_test.py (revision 0)
|
| +++ chrome/common/extensions/docs/server2/rietveld_patcher_test.py (revision 0)
|
| @@ -0,0 +1,67 @@
|
| +#!/usr/bin/env python
|
| +# Copyright 2013 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import os
|
| +import sys
|
| +import unittest
|
| +from appengine_url_fetcher import AppEngineUrlFetcher
|
| +from fake_fetchers import ConfigureFakeFetchers
|
| +from file_system import FileNotFoundError
|
| +from object_store_creator import ObjectStoreCreator
|
| +from rietveld_patcher import RietveldPatcher
|
| +from svn_constants import EXTENSIONS_PATH
|
| +import url_constants
|
| +
|
| +class RietveldPatcherTest(unittest.TestCase):
|
| + def setUp(self):
|
| + ConfigureFakeFetchers(os.path.join(sys.path[0], os.pardir))
|
| + self._patcher = RietveldPatcher(
|
| + EXTENSIONS_PATH,
|
| + '14096030',
|
| + AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER),
|
| + ObjectStoreCreator.Factory('1-0', 'test'))
|
| +
|
| + def _ReadLocalFile(self, filename):
|
| + with open(os.path.join(sys.path[0],
|
| + 'test_data',
|
| + 'rietveld_patcher',
|
| + 'expected',
|
| + filename), 'r') as f:
|
| + return f.read()
|
| +
|
| + def _ApplySingle(self, path):
|
| + return self._patcher.Apply([path], None).Get()[path]
|
| +
|
| + def testGetVersion(self):
|
| + self.assertEqual(self._patcher.GetVersion(), '22002')
|
| +
|
| + def testGetPatchedFiles(self):
|
| + added, deleted, modified = self._patcher.GetPatchedFiles()
|
| + self.assertEqual(sorted(added),
|
| + sorted([
|
| + u'docs/templates/articles/test_foo.html',
|
| + u'docs/templates/public/extensions/test_foo.html']))
|
| + self.assertEqual(sorted(deleted),
|
| + sorted([
|
| + u'docs/templates/public/extensions/runtime.html']))
|
| + self.assertEqual(sorted(modified),
|
| + sorted([
|
| + u'api/test.json',
|
| + u'docs/templates/json/extensions_sidenav.json']))
|
| +
|
| + def testApply(self):
|
| + self.assertEqual(
|
| + self._ReadLocalFile('test_foo.html'),
|
| + self._ApplySingle(
|
| + 'docs/templates/public/extensions/test_foo.html'))
|
| + self.assertEqual(
|
| + self._ReadLocalFile('extensions_sidenav.json'),
|
| + self._ApplySingle(
|
| + 'docs/templates/json/extensions_sidenav.json'))
|
| + self.assertRaises(FileNotFoundError, self._ApplySingle,
|
| + 'docs/templates/public/extensions/runtime.html')
|
| +
|
| +if __name__ == '__main__':
|
| + unittest.main()
|
|
|
| Property changes on: chrome/common/extensions/docs/server2/rietveld_patcher_test.py
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
| Added: svn:executable
|
| + *
|
|
|
|
|