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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
6 import os
7 import unittest
8
9 from environment import GetAppVersionNonMemoized
10
11
12 class EnvironmentTest(unittest.TestCase):
13 def testGetAppVersion(self):
14 # GetAppVersion uses 2 heuristics: the CURRENT_VERSION_ID environment
15 # variable that AppEngine sets, or the version extracted from app.yaml
16 # if no such variable exists (e.g. preview.py). The latter, we assume,
17 # is already tested because AppYamlHelper.ExtractVersion is already
18 # tested. So, for this test, we fake a CURRENT_VERSION_ID.
19 def test_single(expected, current_version_id):
20 key = 'CURRENT_VERSION_ID'
21 old_value = os.environ.get(key)
22 os.environ[key] = current_version_id
23 try:
24 self.assertEqual(expected, GetAppVersionNonMemoized())
25 finally:
26 if old_value is None:
27 del os.environ[key]
28 else:
29 os.environ[key] = old_value
30 def test_all(expected):
31 test_single(expected, expected)
32 test_single(expected, expected + '.48w7dl48wl')
33 test_single(expected, expected + '/48w7dl48wl')
34 test_single(expected, expected + '.48w7dl48wl.w847lw83')
35 test_single(expected, expected + '.48w7dl48wl/w847lw83')
36 test_single(expected, expected + '/48w7dl48wl.w847lw83')
37 test_single(expected, expected + '/48w7dl48wl/w847lw83')
38 test_all('2')
39 test_all('2-0')
40 test_all('2-0-25')
41 test_all('2-0-25-b')
42
43
44 if __name__ == '__main__':
45 unittest.main()
OLDNEW
« 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