Skip to content

Commit

Permalink
fixed issue where the database test to remove would not work
Browse files Browse the repository at this point in the history
  • Loading branch information
LordFarquaadtheCreator committed Sep 2, 2024
1 parent d3a2b1b commit d32743d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def add(self, person: Person):

def remove(self, people: list[str]):
query = self.queries.delete_person
people = [people]
try:
self.execute_query(query, people)
return True
Expand Down
27 changes: 18 additions & 9 deletions Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Test:
def __init__(self):
from Database import Database

self.failed = 0
self.failed = False
self.database = Database()
self.uid_to_delete = ""

Expand All @@ -16,20 +16,29 @@ def load_environment(self):

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_HsadsOST")
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:
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:
self.failed += 1
self.failed = True
print("Failed load environment test")
print(os.environ)
print(e)
return False

Expand All @@ -56,7 +65,7 @@ def add_test(self):
self.uid_to_delete = str(res[0])
return True
except Exception as e:
self.failed += 1
self.failed = True
print("Add Test Unit Test failed\n", e)
return False

Expand All @@ -65,7 +74,7 @@ def delete_test(self):
self.database.remove(self.uid_to_delete)
return True
except Exception as e:
self.failed += 1
self.failed = True
print("Deleting User Test Failed")
print(e)
return False
Expand All @@ -75,7 +84,7 @@ def get_test(self):
_ = self.database.get()
return True
except Exception as e:
self.failed += 1
self.failed = True
print("Get All Values test failed")
print(e)
return False
Expand All @@ -89,7 +98,7 @@ def get_test(self):
ut.get_test()
ut.delete_test()

if ut.failed > 0:
if ut.failed:
print("Tests Failed")
exit(1)
print("Tests Passed!")
Expand Down
2 changes: 1 addition & 1 deletion todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


## Jawad
- [ ] test the delete operation (why is it not working)
- [x] test the delete operation (why is it not working)
- [ ] add current alumni to db
- [ ] add blacklist to db

Expand Down

0 comments on commit d32743d

Please sign in to comment.