aboutsummaryrefslogtreecommitdiff
path: root/tests/dbTestFiller.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-09-22 18:13:35 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-09-22 18:13:35 +0530
commita9c8e275e5d12a4d04b2e6b15180274877e8939a (patch)
tree0dd9b3d36be936d73a26df32df5ca55ec5357f07 /tests/dbTestFiller.py
parent9ef980067d1ee5d9deaa9a587986fc17996053c1 (diff)
added github action and local tests
Diffstat (limited to 'tests/dbTestFiller.py')
-rw-r--r--tests/dbTestFiller.py56
1 files changed, 49 insertions, 7 deletions
diff --git a/tests/dbTestFiller.py b/tests/dbTestFiller.py
index 6971553..5d2b294 100644
--- a/tests/dbTestFiller.py
+++ b/tests/dbTestFiller.py
@@ -1,12 +1,54 @@
+import os
import mysql.connector as con
-import configparser
-config = configparser.ConfigParser()
-config.read('config.ini')
+from mysql.connector.errors import InterfaceError
+
+GitHubWorkflow = True
+
try:
- config['DATABASE']
-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'])
+ print(os.environ['GITHUB_ACTIONS'])
+except:
+ GitHubWorkflow = False
+
+def returnValue(key):
+ return os.environ[key]
+
+if GitHubWorkflow:
+ host = returnValue("CURIE_HOST")
+ db = returnValue("CURIE_DB")
+ user = returnValue("CURIE_USER")
+ port = returnValue("CURIE_PORT")
+ password = returnValue("CURIE_PASSWORD")
+ fromaddr = returnValue("CURIE_EMAIL")
+ emailServer = returnValue("CURIE_EMAIL_SERVER")
+ emailPort = returnValye("CURIE_EMAIL_PORT")
+ emailPassword = returnValye("CURIE_EMAIL_PASSWORD")
+else:
+ import configparser
+ config = configparser.ConfigParser()
+ config.read('config.ini')
+ try:
+ config['DATABASE']
+ except KeyError:
+ config.read("../config.ini")
+ v = config['DATABASE']
+
+ host = v['HOST']
+ db = v['NAME']
+ user = v['USER']
+ password = v['PASSWORD']
+ port = v['PORT']
+ fromaddr = config['SMTP']['EMAIL']
+ emailServer = config['SMTP']['SERVER']
+ emailPort = config['SMTP']['PORT']
+ emailPassword = config['SMTP']['PASSWORD']
+
+
+try:
+ mycon = con.connect(host=host,user=user,password=password,port=port,database=db)
+except InterfaceError:
+ print("Could not connect to the database")
+ sys.exit(1)
+
mycursor = mycon.cursor()
done = 1