Improve the way of getting env values
authorCédric Ollivier <cedric.ollivier@orange.com>
Mon, 12 Feb 2018 15:27:54 +0000 (16:27 +0100)
committerCédric Ollivier <cedric.ollivier@orange.com>
Tue, 13 Feb 2018 06:44:31 +0000 (07:44 +0100)
It simply reads env vars instead of calling CONST.__getattribute__()

Change-Id: If3137f3cfb9f3102388988a82393b9b2f4e99f60
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
functest/cli/commands/cli_os.py
functest/cli/commands/cli_tier.py
functest/tests/unit/cli/commands/test_cli_os.py
functest/tests/unit/cli/test_cli_base.py

index 7595caa..0cf2862 100644 (file)
@@ -20,10 +20,10 @@ from functest.utils.constants import CONST
 class OpenStack(object):
 
     def __init__(self):
-        self.os_auth_url = CONST.__getattribute__('OS_AUTH_URL')
+        self.os_auth_url = os.environ['OS_AUTH_URL']
         self.endpoint_ip = None
         self.endpoint_port = None
-        self.openstack_creds = CONST.__getattribute__('env_file')
+        self.openstack_creds = getattr(CONST, 'env_file')
         if self.os_auth_url:
             self.endpoint_ip = urllib.parse.urlparse(self.os_auth_url).hostname
             self.endpoint_port = urllib.parse.urlparse(self.os_auth_url).port
index 7aa3f71..933d8cd 100644 (file)
@@ -8,12 +8,12 @@
 
 # pylint: disable=missing-docstring
 
+import os
 import pkg_resources
 
 import click
 
 from functest.ci import tier_builder
-from functest.utils.constants import CONST
 from functest.utils import functest_utils
 
 
@@ -21,8 +21,8 @@ class Tier(object):
 
     def __init__(self):
         self.tiers = tier_builder.TierBuilder(
-            CONST.__getattribute__('INSTALLER_TYPE'),
-            CONST.__getattribute__('DEPLOY_SCENARIO'),
+            os.environ['INSTALLER_TYPE'],
+            os.environ['DEPLOY_SCENARIO'],
             pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
 
     def list(self):
index 1626ab1..02392d2 100644 (file)
@@ -26,6 +26,7 @@ class CliOpenStackTesting(unittest.TestCase):
         self.installer_ip = 'test_installer_ip'
         self.openstack_creds = 'test_env_file'
         self.snapshot_file = 'test_snapshot_file'
+        os.environ["OS_AUTH_URL"] = ''
         self.cli_os = cli_os.CliOpenStack()
 
     def test_ping_endpoint_default(self):
index 876e8aa..185a522 100644 (file)
@@ -10,6 +10,7 @@
 # pylint: disable=missing-docstring
 
 import logging
+import os
 import unittest
 
 import mock
@@ -19,6 +20,7 @@ with mock.patch('functest.cli.commands.cli_testcase.CliTestcase.__init__',
                 mock.Mock(return_value=None)), \
     mock.patch('functest.cli.commands.cli_tier.CliTier.__init__',
                mock.Mock(return_value=None)):
+    os.environ['OS_AUTH_URL'] = ''
     from functest.cli import cli_base