diff --git a/tests/test_postfix.py b/tests/test_postfix.py index 10df73987395ab32dff22d4c7cf292e8c74f3e15..11d4a65b4575bd56a8b741a195f8f479a8ed7e8c 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