2 # Copyright 2014 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.
9 from environment
import GetAppVersionNonMemoized
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
24 self
.assertEqual(expected
, GetAppVersionNonMemoized())
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')
44 if __name__
== '__main__':