aboutsummaryrefslogtreecommitdiff
path: root/tests/backendTest.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-09-19 15:49:22 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-09-19 15:49:22 +0530
commitd102cf38a122ed976e684db943b450512c761618 (patch)
treec9c663c7a2b5b76f0ef73237ca36dcd6f17c471e /tests/backendTest.py
parent8ec4944df451e39a289b8f679edc8a9096299c0f (diff)
fix startup crash if database not found
Diffstat (limited to 'tests/backendTest.py')
-rw-r--r--tests/backendTest.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/backendTest.py b/tests/backendTest.py
index 0965e0a..12cefad 100644
--- a/tests/backendTest.py
+++ b/tests/backendTest.py
@@ -1,5 +1,6 @@
import mysql.connector as con
-
+from mysql.connector.errors import InterfaceError
+import sys
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
@@ -9,7 +10,11 @@ try:
except KeyError:
config.read("../config.ini")
-mycon = con.connect(host=config['DATABASE']['HOST'],user=config['DATABASE']['USER'],password=config['DATABASE']['PASSWORD'],port=config['DATABASE']['PORT'],database=config['DATABASE']['NAME'])
+try:
+ mycon = con.connect(host=config['DATABASE']['HOST'],user=config['DATABASE']['USER'],password=config['DATABASE']['PASSWORD'],port=config['DATABASE']['PORT'],database=config['DATABASE']['NAME'])
+except InterfaceError:
+ print("Could not connect to the database")
+ sys.exit(1)
mycursor = mycon.cursor()
# If we are running the CI on an actual server, try using the 6LU7 Mpro and Geraniin Job ID because Eucalyptol fails