Set the DB variables in setup.py
parent
c6e984f2f9
commit
82ef8c4d40
|
@ -13,20 +13,4 @@ repos:
|
||||||
stages: [commit]
|
stages: [commit]
|
||||||
language: system
|
language: system
|
||||||
entry: black
|
entry: black
|
||||||
types: [python]
|
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
|
|
|
@ -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")
|
|
@ -1,20 +1,15 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import psycopg2
|
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):
|
class DatabaseConnection(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = psycopg2.connect(host=db_host,
|
self.conn = psycopg2.connect(
|
||||||
user=db_user,
|
host=db_host, user=db_user, password=db_password, database=db_database,
|
||||||
password=os.getenv("DB_PASSWORD"),
|
)
|
||||||
database=db_database)
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
Loading…
Reference in New Issue