From 82ef8c4d40292c34a9637de56cbb8aa8c7e2a545 Mon Sep 17 00:00:00 2001 From: junos Date: Thu, 24 Dec 2020 14:29:47 +0100 Subject: [PATCH] Set the DB variables in setup.py --- .pre-commit-config.yaml | 18 +----------------- setup.py | 11 +++++++++++ test/database.py | 15 +++++---------- 3 files changed, 17 insertions(+), 27 deletions(-) create mode 100644 setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4617a1c..6552856 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,20 +13,4 @@ repos: stages: [commit] language: system entry: black - types: [python] - - - id: flake8 - name: flake8 - stages: [commit] - language: system - entry: flake8 - types: [python] - exclude: setup.py - - - id: mypy - name: mypy - stages: [commit] - language: system - entry: pipenv run mypy - types: [python] - pass_filenames: false \ No newline at end of file + types: [python] \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..fefd675 --- /dev/null +++ b/setup.py @@ -0,0 +1,11 @@ +import os + +from dotenv import load_dotenv + +load_dotenv() + +db_host = "212.235.208.113" +db_database = "staw" +db_user = "staw_db" + +db_password = os.getenv("DB_PASSWORD") diff --git a/test/database.py b/test/database.py index 035ac86..bd9eb15 100644 --- a/test/database.py +++ b/test/database.py @@ -1,20 +1,15 @@ import unittest + import psycopg2 -import os -from dotenv import load_dotenv -load_dotenv() +from setup import db_database, db_host, db_password, db_user -db_host = "212.235.208.113" -db_database = "staw" -db_user = "staw_db" class DatabaseConnection(unittest.TestCase): def setUp(self): - self.conn = psycopg2.connect(host=db_host, - user=db_user, - password=os.getenv("DB_PASSWORD"), - database=db_database) + self.conn = psycopg2.connect( + host=db_host, user=db_user, password=db_password, database=db_database, + ) def tearDown(self): self.conn.close()