Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4697)

Unified Diff: chrome/common/extensions/docs/server2/template_fetcher_test.py

Issue 10500004: Die build.py, Die: Part 2 (LocalFetcher, Handlebar support, build script) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: TemplateFetcher now has dictionary interface Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/template_fetcher_test.py
diff --git a/chrome/common/extensions/docs/server2/template_fetcher_test.py b/chrome/common/extensions/docs/server2/template_fetcher_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..fd42f6068cdff5a137fbd724bcdc30c40727117e
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/template_fetcher_test.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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 unittest
+import test_urlfetch
+
+from local_fetcher import LocalFetcher
+from template_fetcher import TemplateFetcher
+from third_party.handlebar import Handlebar
+
+def _ReadFile(filename):
+ with open(filename, 'r') as f:
+ return f.read()
+
+class TestFetcher(LocalFetcher):
+ def FetchResource(self, branch, path):
+ result = self._Resource()
+ result.content = _ReadFile(os.path.join(self.base_path, branch, path))
+ return result
+
+class TemplateFetcherTest(unittest.TestCase):
+ def testFetcher(self):
+ path = os.path.join('test_data', 'template_fetcher')
+ fetcher = TestFetcher(path)
+ t_fetcher_a = TemplateFetcher('a', fetcher)
+ t_fetcher_b = TemplateFetcher('b', fetcher)
+ t_fetcher_a.FetchTemplate('test1.html')
+ t_fetcher_a.FetchTemplate('test2.html')
+ t_fetcher_b.FetchTemplate('test1.html')
+
+ template_a1 = Handlebar(_ReadFile(os.path.join(path, 'a', 'test1.html')))
+ self.assertEqual(template_a1.render('{}', {'templates': {}}).text,
+ t_fetcher_a['test1.html'].render('{}', {'templates': {}}).text)
+
+ template_a2 = Handlebar(_ReadFile(os.path.join(path, 'a', 'test2.html')))
+ self.assertEqual(template_a2.render('{}', {'templates': {}}).text,
+ t_fetcher_a['test2.html'].render('{}', {'templates': {}}).text)
+
+ template_b1 = Handlebar(_ReadFile(os.path.join(path, 'b', 'test1.html')))
+ self.assertEqual(template_b1.render('{}', {'templates': {}}).text,
+ t_fetcher_b['test1.html'].render('{}', {'templates': {}}).text)
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698