From b527cd0dcc4010ca93674cb718f2965d3f16ed14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu>
Date: Thu, 23 Feb 2017 16:33:17 +0100
Subject: [PATCH] improve printing

---
 tests/test_postfix.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/tests/test_postfix.py b/tests/test_postfix.py
index 10df7398..11d4a65b 100755
--- a/tests/test_postfix.py
+++ b/tests/test_postfix.py
@@ -15,6 +15,11 @@ GREEN = '\033[92m'
 RED = '\033[91m'
 DEF = '\033[0m'
 
+os.chdir(os.path.dirname(__file__))
+if not os.path.isfile('../utils.py'):
+    print('conf.sh not found')
+    sys.exit(1)
+
 def print_color(txt, col):
     print('%s%s%s' % (col, txt, DEF))
 
@@ -33,16 +38,17 @@ def get_configured_relay():
 
 def check_relay():
     global all_ok
+    global conf
     configured_relay = get_configured_relay()
-
     print('Checking if SMTP relay conforms to conf')
-    if os.path.isfile('../utils.py'):
-        es_utils = imp.load_source('es_utils', '../utils.py')
-        conf = es_utils.load_conf()
-        conf_relay = conf.get('EMAIL_SMTP_SERVER')
-        if conf_relay != configured_relay:
-            print_red('Configured STMP relay (%s) does not match the expected value (%s)' % (configured_relay, conf_relay))
-            all_ok = False
+    es_utils = imp.load_source('es_utils', '../utils.py')
+    conf = es_utils.load_conf()
+    conf_relay = conf.get('EMAIL_SMTP_SERVER')
+    if conf_relay != configured_relay:
+        print_red('Configured STMP relay (%s) does not match the expected value (%s)' % (configured_relay, conf_relay))
+        all_ok = False
+    else:
+        print_green('STMP relay is properly set')
 
 def send_test_email():
     global all_ok
-- 
GitLab