From 7c6ae2df5a2286ea036fe287c972b43058a1a0eb Mon Sep 17 00:00:00 2001 From: "Chanwut (Mick) Kittivorawong" Date: Sun, 25 Feb 2024 01:55:10 -0800 Subject: [PATCH] fix reset --- tests/engine/test_database.py | 48 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/tests/engine/test_database.py b/tests/engine/test_database.py index 6d72798..6afe1ef 100644 --- a/tests/engine/test_database.py +++ b/tests/engine/test_database.py @@ -17,10 +17,8 @@ def test_reset(): d = Database(psycopg2.connect( dbname="mobilitydb", user="docker", - # host="localhost", - # port=os.environ["AP_PORT_RESET"], - host='store', - port='5432', + host="localhost", + port=os.environ["AP_PORT_RESET"], password="docker", )) @@ -43,29 +41,29 @@ def test_reset(): assert d.sql("select * from " + t).empty -# def test_execute_update_and_query(): -# d = Database(psycopg2.connect( -# dbname="mobilitydb", -# user="docker", -# host="localhost", -# port=os.environ["AP_PORT_SQL"], -# password="docker", -# )) +def test_execute_update_and_query(): + d = Database(psycopg2.connect( + dbname="mobilitydb", + user="docker", + host="localhost", + port=os.environ["AP_PORT_SQL"], + password="docker", + )) -# d.update("create table if not exists t1 (c1 text, c2 int)") -# d.update("insert into t1 values ('test1', 3), ('test2', 4)") -# d._commit() -# results = d.execute("select * from t1") -# assert results == [("test1", 3), ("test2", 4)], "should return correct tuples" + d.update("create table if not exists t1 (c1 text, c2 int)") + d.update("insert into t1 values ('test1', 3), ('test2', 4)") + d._commit() + results = d.execute("select * from t1") + assert results == [("test1", 3), ("test2", 4)], "should return correct tuples" -# with pytest.raises(psycopg2.errors.DatabaseError): -# d.update("zxcvasdfqwer") + with pytest.raises(psycopg2.errors.DatabaseError): + d.update("zxcvasdfqwer") -# results = d.execute("select * from t1") -# assert results == [("test1", 3), ("test2", 4)], "should execute another query after failed executions" + results = d.execute("select * from t1") + assert results == [("test1", 3), ("test2", 4)], "should execute another query after failed executions" -# with pytest.raises(psycopg2.errors.DatabaseError): -# d.execute("zxcvasdfqwer") + with pytest.raises(psycopg2.errors.DatabaseError): + d.execute("zxcvasdfqwer") -# results = d.execute("select * from t1") -# assert results == [("test1", 3), ("test2", 4)], "should execute another query after failed executions" + results = d.execute("select * from t1") + assert results == [("test1", 3), ("test2", 4)], "should execute another query after failed executions"