Set the DB variables in setup.py

communication
junos 2020-12-24 14:29:47 +01:00
parent c6e984f2f9
commit 82ef8c4d40
3 changed files with 17 additions and 27 deletions

View File

@ -14,19 +14,3 @@ repos:
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

11
setup.py 100644
View File

@ -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")

View File

@ -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()