3 # Copyright (c) 2018 Orange and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # pylint: disable=missing-docstring
16 from six.moves import reload_module
18 from functest.utils import env
21 class EnvTesting(unittest.TestCase):
22 # pylint: disable=missing-docstring
25 os.environ['FOO'] = 'foo'
26 os.environ['BUILD_TAG'] = 'master'
27 os.environ['CI_LOOP'] = 'weekly'
29 def test_get_unset_unknown_env(self):
31 self.assertEqual(env.get('FOO'), None)
33 def test_get_unknown_env(self):
34 self.assertEqual(env.get('FOO'), 'foo')
37 def test_get_unset_env(self):
38 del os.environ['CI_LOOP']
40 env.get('CI_LOOP'), env.INPUTS['CI_LOOP'])
42 def test_get_env(self):
44 env.get('CI_LOOP'), 'weekly')
46 def test_get_unset_env2(self):
47 del os.environ['BUILD_TAG']
49 env.get('BUILD_TAG'), env.INPUTS['BUILD_TAG'])
51 def test_get_env2(self):
52 self.assertEqual(env.get('BUILD_TAG'), 'master')
55 if __name__ == "__main__":
56 logging.disable(logging.CRITICAL)
57 unittest.main(verbosity=2)