Rename FormConfig.callback to FormConfig.run_script.

pull/7/head
Ferry Boender 10 years ago
parent 01161bcd07
commit 66a7a134ff
  1. 2
      src/formconfig.py
  2. 4
      src/webapp.py
  3. 6
      test/test.py

@ -68,7 +68,7 @@ class FormConfig(object):
form_list.append(form_def) form_list.append(form_def)
return form_list return form_list
def callback(self, form_name, form_values, stdout=None, stderr=None): def run_script(self, form_name, form_values, stdout=None, stderr=None):
""" """
Perform a callback for the form `form_name`. This calls a script. Perform a callback for the form `form_name`. This calls a script.
`form_values` is a dictionary of validated values as returned by `form_values` is a dictionary of validated values as returned by

@ -410,8 +410,8 @@ class ScriptFormWebApp(RequestHandler):
log.info("User: {0}".format(username)) log.info("User: {0}".format(username))
log.info("Variables: {0}".format(dict(form_values.items()))) log.info("Variables: {0}".format(dict(form_values.items())))
result = form_config.callback(form_name, form_values, self.wfile, result = form_config.run_script(form_name, form_values, self.wfile,
self.wfile) self.wfile)
if form_def.output != 'raw': if form_def.output != 'raw':
# Ignore everything if we're doing raw output, since it's the # Ignore everything if we're doing raw output, since it's the
# scripts responsibility. # scripts responsibility.

@ -49,7 +49,7 @@ class FormConfigTestCase(unittest.TestCase):
"""Test a callback that returns output in strings""" """Test a callback that returns output in strings"""
sf = scriptform.ScriptForm('test_formconfig_callback.json') sf = scriptform.ScriptForm('test_formconfig_callback.json')
fc = sf.get_form_config() fc = sf.get_form_config()
res = fc.callback('test_store', {}) res = fc.run_script('test_store', {})
self.assertEquals(res['exitcode'], 33) self.assertEquals(res['exitcode'], 33)
self.assertTrue('stdout' in res['stdout']) self.assertTrue('stdout' in res['stdout'])
self.assertTrue('stderr' in res['stderr']) self.assertTrue('stderr' in res['stderr'])
@ -60,7 +60,7 @@ class FormConfigTestCase(unittest.TestCase):
fc = sf.get_form_config() fc = sf.get_form_config()
stdout = file('tmp_stdout', 'w+') # can't use StringIO stdout = file('tmp_stdout', 'w+') # can't use StringIO
stderr = file('tmp_stderr', 'w+') stderr = file('tmp_stderr', 'w+')
exitcode = fc.callback('test_raw', {}, stdout, stderr) exitcode = fc.run_script('test_raw', {}, stdout, stderr)
stdout.seek(0) stdout.seek(0)
stderr.seek(0) stderr.seek(0)
self.assertTrue(exitcode == 33) self.assertTrue(exitcode == 33)
@ -71,7 +71,7 @@ class FormConfigTestCase(unittest.TestCase):
""" """
sf = scriptform.ScriptForm('test_formconfig_callback.json') sf = scriptform.ScriptForm('test_formconfig_callback.json')
fc = sf.get_form_config() fc = sf.get_form_config()
self.assertRaises(ValueError, fc.callback, 'test_raw', {}) self.assertRaises(ValueError, fc.run_script, 'test_raw', {})
class FormDefinitionTest(unittest.TestCase): class FormDefinitionTest(unittest.TestCase):

Loading…
Cancel
Save