Skip to content

Commit

Permalink
[sextante]improved classes for creating unit tests from GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Mar 23, 2013
1 parent 9465afa commit 176a08c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 1 addition & 9 deletions python/plugins/sextante/gui/HistoryDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,11 @@ def changeText(self):
if isinstance(item, TreeLogEntryItem):
self.text.setText(item.entry.text.replace("|","\n"))



def createTest(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
if item.isAlg:
TestTools.createTest(item)






TestTools.createTest(item.entry.text)

def showPopupMenu(self,point):
item = self.tree.currentItem()
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/sextante/gui/TestTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.outputs.OutputVector import OutputVector

def createTest(item):
def createTest(text):
s = ""
tokens = item.entry.text[len("sextante.runalg("):-1].split(",")
tokens = text[len("sextante.runalg("):-1].split(",")
cmdname = tokens[0][1:-1];
methodname = "test_" + cmdname.replace(":","")
s += "def " + methodname + "():\n"
Expand All @@ -44,7 +44,7 @@ def createTest(item):
for token in tokens:
if i < alg.getVisibleParametersCount() + 1:
if os.path.exists(token[1:-1]):
token = '"' + os.path.basename(token[1:-1])[:-4] + '"'
token = os.path.basename(token[1:-1])[:-4]
execcommand+=token + ","
else:
execcommand+="None,"
Expand All @@ -69,8 +69,8 @@ def createTest(item):
fields = layer.pendingFields()
s+="\tlayer=sextante.getobject(output)\n"
s+="\tfields=layer.pendingFields()\n"
s+="\texpectednames=[" + ",".join([str(f.name()) for f in fields]) + "]\n"
s+="\texpectedtypes=[" + ",".join([str(f.typeName()) for f in fields]) + "]\n"
s+="\texpectednames=[" + ",".join(["'" + str(f.name()) + "'" for f in fields]) + "]\n"
s+="\texpectedtypes=[" + ",".join(["'" + str(f.typeName()) +"'" for f in fields]) + "]\n"
s+="\tnames=[str(f.name()) for f in fields]\n"
s+="\ttypes=[str(f.typeName()) for f in fields]\n"
s+="\tself.assertEqual(expectednames, names)\n"
Expand Down

0 comments on commit 176a08c

Please sign in to comment.