diff --git a/Test.py b/Test.py index da24cd3..352abd5 100644 --- a/Test.py +++ b/Test.py @@ -5,8 +5,9 @@ class Test: def __init__(self): from Database import Database - self.passed_counter = 0 + self.failed = 0 self.database = Database() + self.uid_to_delete = "" def load_environment(self): try: @@ -20,11 +21,10 @@ def load_environment(self): _ = os.getenv("POSTGRESQL_DB_PASSWORD") _ = os.getenv("POSTGRESQL_DB_HOST") _ = os.getenv("POSTGRESQL_DB_PORT") - - self.passed_counter += 1 return True except Exception as e: + self.failed += 1 print("Failed load environment test") print(e) return False @@ -50,18 +50,18 @@ def add_test(self): try: res = self.database.add(t)[0] self.uid_to_delete = str(res[0]) - self.passed_counter += 1 return True except Exception as e: + self.failed += 1 print("Add Test Unit Test failed\n", e) return False def delete_test(self): try: self.database.remove(self.uid_to_delete) - self.passed_counter += 1 return True except Exception as e: + self.failed += 1 print("Deleting User Test Failed") print(e) return False @@ -69,9 +69,9 @@ def delete_test(self): def get_test(self): try: _ = self.database.get() - self.passed_counter += 1 return True except Exception as e: + self.failed += 1 print("Get All Values test failed") print(e) return False @@ -79,7 +79,14 @@ def get_test(self): if __name__ == "__main__": ut = UnitTest() - assert ut.load_environment() is True - assert ut.add_test() is True - assert ut.get_test() is True - assert ut.delete_test() is True + + ut.load_environment() + ut.add_test() + ut.get_test() + ut.delete_test() + + if ut.failed > 0: + print("Tests Failed") + exit(1) + print("Tests Passed!") + exit(0)