Skip to content
This repository has been archived by the owner on Jun 4, 2020. It is now read-only.

Commit

Permalink
Final commit prior to PR for the diffmode branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Yves Moisan committed Feb 9, 2016
1 parent 4133d2a commit 2daecf6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
42 changes: 32 additions & 10 deletions test/versioning_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,48 @@
#print "select_str = " + select_str
pcur.execute(select_str)
res = pcur.fetchall()
print "fetchall 1 vs 2 = " + str(res)

select_and_where_str = versioning_base.rev_view_str(pg_conn_info, 'epanet', 'junctions','trunk', 1)
select_str = select_and_where_str[0]
where_str = select_and_where_str[1]
assert(res[0][0] == 'u')
#print "fetchall 1 vs 2 = " + str(res)
#fetchall 1 vs 2 = [
#('u', 3, '1', 8.0, None, None, '01010000206A0800000000000000000000000000000000F03F', 2, 2, 2, 4)]

select_str = versioning_base.diff_rev_view_str(pg_conn_info, 'epanet', 'junctions','trunk', 1,3)
#print "select_str = " + select_str
pcur.execute(select_str)
res = pcur.fetchall()
print "fetchall 1 vs 3 = " + str(res)
#print "fetchall 1 vs 3 = " + str(res)
#fetchall 1 vs 3 = [
#('u', 4, '1', 22.0, None, None, '01010000206A0800000000000000000000000000000000F03F', 3, None, 3, None),
#('i', 3, '1', 8.0, None, None, '01010000206A0800000000000000000000000000000000F03F', 2, 2, 2, 4)]
assert(res[0][0] == 'u')
assert(res[1][0] == 'i')

select_str = versioning_base.diff_rev_view_str(pg_conn_info, 'epanet', 'junctions','trunk', 1,4)
print "select_str 1 vs 4 = " + select_str
#print "select_str 1 vs 4 = " + select_str
pcur.execute(select_str)
res = pcur.fetchall()
print "fetchall 1 vs 4 = " + str(res)
#print "fetchall 1 vs 4 = " + str(res)
#fetchall 1 vs 4 = [
#('u', 4, '1', 22.0, None, None, '01010000206A0800000000000000000000000000000000F03F', 3, None, 3, None),
#('i', 3, '1', 8.0, None, None, '01010000206A0800000000000000000000000000000000F03F', 2, 2, 2, 4),
#('a', 5, '10', 100.0, None, None, '01010000206A08000000000000000000400000000000000000', 4, None, None, None),
#('i', 1, '0', 0.0, None, None, '01010000206A080000000000000000F03F0000000000000000', 1, 4, None, None)]
assert(res[0][0] == 'u')
assert(res[1][0] == 'i')
assert(res[2][0] == 'a')
assert(res[3][0] == 'i') # object is in intermediate state; will be deleted in rev 5

select_str = versioning_base.diff_rev_view_str(pg_conn_info, 'epanet', 'junctions','trunk', 1,5)
print "select_str 1 vs 5 = " + select_str
#print "select_str 1 vs 5 = " + select_str
pcur.execute(select_str)
res = pcur.fetchall()
print "fetchall 1 vs 5 = " + str(res)
#print "fetchall 1 vs 5 = " + str(res)
#fetchall 1 vs 5 = [
#('u', 4, '1', 22.0, None, None, '01010000206A0800000000000000000000000000000000F03F', 3, None, 3, None),
#('i', 3, '1', 8.0, None, None, '01010000206A0800000000000000000000000000000000F03F', 2, 2, 2, 4),
#('a', 5, '10', 100.0, None, None, '01010000206A08000000000000000000400000000000000000', 4, None, None, None),
#('d', 1, '0', 0.0, None, None, '01010000206A080000000000000000F03F0000000000000000', 1, 4, None, None)]
assert(res[0][0] == 'u')
assert(res[1][0] == 'i')
assert(res[2][0] == 'a')
assert(res[3][0] == 'd')
2 changes: 1 addition & 1 deletion versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def view(self):

pcur = versioning_base.Db( psycopg2.connect(self.pg_conn_info()) )
pcur.execute("SELECT rev, author, date::timestamp(0), branch, commit_msg "
"FROM "+schema+".revisions")
"FROM "+schema+".revisions ORDER BY rev ASC")
revs = pcur.fetchall()
pcur.close()

Expand Down
2 changes: 1 addition & 1 deletion versioning_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ def diff_rev_view_str(pg_conn_info, schema, table, branch, rev_begin, rev_end):
"AND "+schema+"."+table+"."+branch+"_child IS NOT NULL) "
"THEN 'u' "
"WHEN " +schema+"."+table+"."+branch+"_rev_end > "+str(rev_begin)+ " "
"AND " +schema+"."+table+"."+branch+"_rev_end <= "+str(rev_end)+ " "
"AND " +schema+"."+table+"."+branch+"_rev_end < "+str(rev_end)+ " "
"AND " +schema+"."+table+"."+branch+"_child IS NULL THEN 'd' ELSE 'i' END "
"as diff_status, * FROM "+schema+"."+table+ " "
"WHERE (" +schema+"."+table+"."+branch+"_rev_begin > "+str(rev_begin)+ " "
Expand Down

0 comments on commit 2daecf6

Please sign in to comment.