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

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

Issue 297963004: Docserver: Update app version parsing since AppEngine started including / (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 6 years, 7 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/environment_test.py
diff --git a/chrome/common/extensions/docs/server2/environment_test.py b/chrome/common/extensions/docs/server2/environment_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..5476dd51a7acd61dfeb8cbf6bffe4e3004208503
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/environment_test.py
@@ -0,0 +1,45 @@
+#!/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 unittest
+
+from environment import GetAppVersionNonMemoized
+
+
+class EnvironmentTest(unittest.TestCase):
+ def testGetAppVersion(self):
+ # GetAppVersion uses 2 heuristics: the CURRENT_VERSION_ID environment
+ # variable that AppEngine sets, or the version extracted from app.yaml
+ # if no such variable exists (e.g. preview.py). The latter, we assume,
+ # is already tested because AppYamlHelper.ExtractVersion is already
+ # tested. So, for this test, we fake a CURRENT_VERSION_ID.
+ def test_single(expected, current_version_id):
+ key = 'CURRENT_VERSION_ID'
+ old_value = os.environ.get(key)
+ os.environ[key] = current_version_id
+ try:
+ self.assertEqual(expected, GetAppVersionNonMemoized())
+ finally:
+ if old_value is None:
+ del os.environ[key]
+ else:
+ os.environ[key] = old_value
+ def test_all(expected):
+ test_single(expected, expected)
+ test_single(expected, expected + '.48w7dl48wl')
+ test_single(expected, expected + '/48w7dl48wl')
+ test_single(expected, expected + '.48w7dl48wl.w847lw83')
+ test_single(expected, expected + '.48w7dl48wl/w847lw83')
+ test_single(expected, expected + '/48w7dl48wl.w847lw83')
+ test_single(expected, expected + '/48w7dl48wl/w847lw83')
+ test_all('2')
+ test_all('2-0')
+ test_all('2-0-25')
+ test_all('2-0-25-b')
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « chrome/common/extensions/docs/server2/environment.py ('k') | chrome/common/extensions/docs/server2/object_store_creator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698