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

Commit

Permalink
refacto test to be run individually in qgis console
Browse files Browse the repository at this point in the history
  • Loading branch information
vmora committed Apr 10, 2017
1 parent 918743b commit 2015329
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 27 deletions.
4 changes: 3 additions & 1 deletion test/abbreviation_bug_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import tempfile

if __name__ == "__main__":
def test():
tmp_dir = tempfile.gettempdir()
test_data_dir = os.path.dirname(os.path.realpath(__file__))

Expand Down Expand Up @@ -62,4 +62,6 @@
assert row[1].find('this_is_another_edited_very_long_name_that should_be_trunctated_if_buggy') != -1\
or row[1].find('newly inserted with long name') != -1

if __name__ == "__main__":
test()

5 changes: 4 additions & 1 deletion test/history_creation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import shutil
import tempfile

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()

Expand Down Expand Up @@ -104,3 +104,6 @@
assert( len(pcur.fetchall()) == 1 )

pcur.close()

if __name__ == "__main__":
test()
7 changes: 5 additions & 2 deletions test/issue287_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import shutil
import tempfile

if __name__ == "__main__":

def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()

Expand All @@ -21,3 +20,7 @@
shutil.copyfile(test_data_dir+"/issue287_wc.sqlite", tmp_dir+"/issue287_wc.sqlite")
versioning.update(tmp_dir+"/issue287_wc.sqlite", "dbname=epanet_test_db")
versioning.commit(tmp_dir+"/issue287_wc.sqlite", "test message", "dbname=epanet_test_db")

if __name__ == "__main__":
test()

4 changes: 3 additions & 1 deletion test/issue357_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import tempfile

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()

Expand Down Expand Up @@ -93,3 +93,5 @@
for r in scur[1].fetchall():
print r

if __name__ == "__main__":
test()
5 changes: 4 additions & 1 deletion test/issue358_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import tempfile

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()

Expand All @@ -32,3 +32,6 @@
scur.execute("UPDATE pipes_view SET length = 2 WHERE OGC_FID = 2")
scur.execute("SELECT * FROM pipes")
assert( len(scur.fetchall()) == 2 )

if __name__ == "__main__":
test()
4 changes: 3 additions & 1 deletion test/issue437_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import tempfile

if __name__ == "__main__":
def test():

test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()
Expand Down Expand Up @@ -94,3 +94,5 @@
for r in scur[1].fetchall():
print r

if __name__ == "__main__":
test()
5 changes: 4 additions & 1 deletion test/issue485_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import tempfile

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()

Expand Down Expand Up @@ -160,3 +160,6 @@
print "-----------------"
for r in pcur.fetchall(): print r
pcur.close()

if __name__ == "__main__":
test()
4 changes: 3 additions & 1 deletion test/issue486_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import tempfile

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()

Expand Down Expand Up @@ -101,3 +101,5 @@

pcur.close()

if __name__ == "__main__":
test()
5 changes: 4 additions & 1 deletion test/multiple_geometry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
import tempfile

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))
tmp_dir = tempfile.gettempdir()

Expand Down Expand Up @@ -132,3 +132,6 @@
assert( res[0][0] == 'POINT(3 3)' )
assert( res[1][1] == 'POLYGON((0 0,2 0,2 2,0 2,0 0))' )
pcur.close()

if __name__ == "__main__":
test()
5 changes: 4 additions & 1 deletion test/partial_checkout_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import tempfile

if __name__ == "__main__":
def test():
tmp_dir = tempfile.gettempdir()
test_data_dir = os.path.dirname(os.path.realpath(__file__))

Expand Down Expand Up @@ -46,3 +46,6 @@
scur = scon.cursor()
scur.execute("SELECT * from junctions")
assert len(scur.fetchall()) == 3

if __name__ == "__main__":
test()
12 changes: 7 additions & 5 deletions test/posgres_working_copy_bug_in_conflict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

def prtTab( cur, tab ):
print "--- ",tab," ---"
pcur.execute("SELECT pid, trunk_rev_begin, trunk_rev_end, trunk_parent, trunk_child, length FROM "+tab)
for r in pcur.fetchall():
cur.execute("SELECT pid, trunk_rev_begin, trunk_rev_end, trunk_parent, trunk_child, length FROM "+tab)
for r in cur.fetchall():
t = []
for i in r: t.append(str(i))
print '\t| '.join(t)

def prtHid( cur, tab ):
print "--- ",tab," ---"
pcur.execute("SELECT pid FROM "+tab)
for [r] in pcur.fetchall(): print r
cur.execute("SELECT pid FROM "+tab)
for [r] in cur.fetchall(): print r

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))

# create the test database
Expand Down Expand Up @@ -65,3 +65,5 @@ def prtHid( cur, tab ):
pcur.close()


if __name__ == "__main__":
test()
13 changes: 8 additions & 5 deletions test/posgres_working_copy_bug_in_view_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

def prtTab( cur, tab ):
print "--- ",tab," ---"
pcur.execute("SELECT pid, trunk_rev_begin, trunk_rev_end, trunk_parent, trunk_child, length FROM "+tab)
for r in pcur.fetchall():
cur.execute("SELECT pid, trunk_rev_begin, trunk_rev_end, trunk_parent, trunk_child, length FROM "+tab)
for r in cur.fetchall():
t = []
for i in r: t.append(str(i))
print '\t| '.join(t)

def prtHid( cur, tab ):
print "--- ",tab," ---"
pcur.execute("SELECT pid FROM "+tab)
for [r] in pcur.fetchall(): print r
cur.execute("SELECT pid FROM "+tab)
for [r] in cur.fetchall(): print r

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))

# create the test database
Expand All @@ -38,3 +38,6 @@ def prtHid( cur, tab ):
prtHid( pcur, 'epanet_working_copy.pipes_view')
pcur.execute("SElECT COUNT(pid) FROM epanet_working_copy.pipes_view")
assert( 1 == pcur.fetchone()[0] )

if __name__ == "__main__":
test()
12 changes: 7 additions & 5 deletions test/posgres_working_copy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

def prtTab( cur, tab ):
print "--- ",tab," ---"
pcur.execute("SELECT pid, trunk_rev_begin, trunk_rev_end, trunk_parent, trunk_child, length FROM "+tab)
for r in pcur.fetchall():
cur.execute("SELECT pid, trunk_rev_begin, trunk_rev_end, trunk_parent, trunk_child, length FROM "+tab)
for r in cur.fetchall():
t = []
for i in r: t.append(str(i))
print '\t| '.join(t)

def prtHid( cur, tab ):
print "--- ",tab," ---"
pcur.execute("SELECT pid FROM "+tab)
for [r] in pcur.fetchall(): print r
cur.execute("SELECT pid FROM "+tab)
for [r] in cur.fetchall(): print r

if __name__ == "__main__":
def test():
test_data_dir = os.path.dirname(os.path.realpath(__file__))

# create the test database
Expand Down Expand Up @@ -133,3 +133,5 @@ def prtHid( cur, tab ):
pcur.execute("UPDATE epanet_working_copy_cflt.pipes_view SET length = 12")
pcur.commit()

if __name__ == "__main__":
test()
5 changes: 4 additions & 1 deletion test/versioning_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import tempfile

if __name__ == "__main__":
def test():
tmp_dir = tempfile.gettempdir()
test_data_dir = os.path.dirname(os.path.realpath(__file__))

Expand Down Expand Up @@ -146,3 +146,6 @@
#('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)]

if __name__ == "__main__":
test()

0 comments on commit 2015329

Please sign in to comment.