Test a script callback that returns non-zero exit code via the Web app.

pull/7/head
Ferry Boender 10 years ago
parent 561c566719
commit 67cc44993a
  1. 8
      test/test.py
  2. 8
      test/test_webapp.json
  3. 6
      test/test_webapp_cb_fail.sh

@ -86,6 +86,7 @@ class FormConfigTestCase(unittest.TestCase):
fc = sf.get_form_config() fc = sf.get_form_config()
self.assertRaises(ValueError, fc.callback, 'test_raw', {}) self.assertRaises(ValueError, fc.callback, 'test_raw', {})
class FormDefinitionTest(unittest.TestCase): class FormDefinitionTest(unittest.TestCase):
""" """
Form Definition tests. Mostly directly testing if validations work. Form Definition tests. Mostly directly testing if validations work.
@ -391,6 +392,13 @@ class WebAppTest(unittest.TestCase):
r = requests.get('http://localhost:8002/form?form_name=hidden_field', auth=self.auth_user) r = requests.get('http://localhost:8002/form?form_name=hidden_field', auth=self.auth_user)
self.assertIn('class="hidden"', r.text) self.assertIn('class="hidden"', r.text)
def testCallbackFail(self):
data = {
"form_name": "callback_fail"
}
r = requests.post("http://localhost:8002/submit", data=data, auth=self.auth_user)
self.assertIn('<span class="error">stderr output\n</span>', r.text)
class WebAppSingleTest(unittest.TestCase): class WebAppSingleTest(unittest.TestCase):
""" """

@ -167,6 +167,14 @@
"hidden": true "hidden": true
} }
] ]
},
{
"name": "callback_fail",
"title": "callback fail",
"description": "Callback fail",
"script": "test_webapp_cb_fail.sh",
"fields": [
]
} }
] ]
} }

@ -0,0 +1,6 @@
#!/bin/sh
echo "stdout output"
echo "stderr output" >&2
exit 1
Loading…
Cancel
Save