Skip to content

Commit

Permalink
fix reset
Browse files Browse the repository at this point in the history
  • Loading branch information
chanwutk committed Feb 25, 2024
1 parent 9a53039 commit 7c6ae2d
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions tests/engine/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
))

Expand All @@ -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"

0 comments on commit 7c6ae2d

Please sign in to comment.