Skip to content
Snippets Groups Projects
Commit 3da78e5c authored by Peter J. Keleher's avatar Peter J. Keleher
Browse files

auto

parent 7c21f088
No related branches found
No related tags found
No related merge requests found
......@@ -5,38 +5,38 @@ import subprocess
def executePrint(s):
cur.execute(s)
print cur.fetchall()
print(cur.fetchall())
subprocess.call(["psql", "-f", "/vagrant/trigger.sql", "flightsskewed"])
conn = psycopg2.connect("dbname=flightsskewed user=vagrant")
conn = psycopg2.connect("dbname=flightsskewed user=ubuntu")
cur = conn.cursor()
## Add a customer who doesn't exist
print "==== Testing: adding a customer without a flewon entry"
print("==== Testing: adding a customer without a flewon entry")
executePrint("select * from NumberOfFlightsTaken where customerid = 'cust731'")
print "Inserting a flewon entry for cust731"
print("Inserting a flewon entry for cust731")
cur.execute("insert into flewon values ('AA101', 'cust731', to_date('2016-08-09', 'YYYY-MM-DD'))");
conn.commit()
print "Rerunning the query"
print("Rerunning the query")
executePrint("select * from NumberOfFlightsTaken where customerid = 'cust731'")
## Remove a customer with a few entries
print "==== Testing: removing a customer's all flewon entries"
print("==== Testing: removing a customer's all flewon entries")
executePrint("select * from NumberOfFlightsTaken where customerid = 'cust597'")
cur.execute("delete from flewon where customerid = 'cust597' and flightid = 'F9103'")
conn.commit()
print "Rerunning the query after deleting one entry"
print("Rerunning the query after deleting one entry")
executePrint("select * from NumberOfFlightsTaken where customerid = 'cust597'")
cur.execute("delete from flewon where customerid = 'cust597' and flightid = 'AA134'")
conn.commit()
print "Rerunning the query after deleting both entries"
print("Rerunning the query after deleting both entries")
executePrint("select * from NumberOfFlightsTaken where customerid = 'cust597'")
## Cleanup
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment