Skip to content

Commit

Permalink
refactored load env test
Browse files Browse the repository at this point in the history
  • Loading branch information
LordFarquaadtheCreator committed Sep 3, 2024
1 parent 2db0ff8 commit 50a5401
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,31 @@ def __init__(self):
self.uid_to_delete = ""

def load_environment(self):
try:
import os
from dotenv import load_dotenv

load_dotenv()

user = os.getenv("USERNAME")
password = os.getenv("PASSWORD")
db = os.getenv("POSTGRESQL_DB")
db_user = os.getenv("POSTGRESQL_DB_USER")
db_pass = os.getenv("POSTGRESQL_DB_PASSWORD")
db_host = os.getenv("POSTGRESQL_DB_HOST")
db_port = os.getenv("POSTGRESQL_DB_PORT")

if (
not db
or not db_user
or not db_pass
or not db_host
or not db_port
or not password
or not user
):
raise Exception("Missing Certain Environment Variables")
return True

except Exception as e:
import os
from dotenv import load_dotenv

load_dotenv()

user = os.getenv("USERNAME")
password = os.getenv("PASSWORD")
db = os.getenv("POSTGRESQL_DB")
db_user = os.getenv("POSTGRESQL_DB_USER")
db_pass = os.getenv("POSTGRESQL_DB_PASSWORD")
db_host = os.getenv("POSTGRESQL_DB_HOST")
db_port = os.getenv("POSTGRESQL_DB_PORT")

if (
not db
or not db_user
or not db_pass
or not db_host
or not db_port
or not password
or not user
):
print(user, password, db, db_host, db_pass, db_port, db_user)
raise e
raise Exception("Missing Certain Environment Variables")
return True


class UnitTest(Test):
Expand Down

0 comments on commit 50a5401

Please sign in to comment.