From 16c8d5818a81bf234f9ec99b53ebe8352c92da80 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Mon, 29 Jun 2015 17:56:08 +0200 Subject: [PATCH] Added: Testcase to determine that Scriptform shows the form directly if there's only one form. --- test/test.py | 33 ++++++++++++++++++++++++++++++++ test/test_webapp_singleform.json | 12 ++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/test_webapp_singleform.json diff --git a/test/test.py b/test/test.py index 34183ea..d9a01e3 100644 --- a/test/test.py +++ b/test/test.py @@ -323,6 +323,39 @@ class WebAppTest(unittest.TestCase): self.assertEquals(f_orig, f_served) +class WebAppSingleTest(unittest.TestCase): + """ + Test that Scriptform doesn't show us a list of forms, but directly shows us + the form is there's only one. + """ + @classmethod + def setUpClass(cls): + def server_thread(sf): + sf.run(listen_port=8002) + cls.sf = scriptform.ScriptForm('test_webapp_singleform.json') + thread.start_new_thread(server_thread, (cls.sf, )) + # Wait until the webserver is ready + while True: + time.sleep(0.1) + if cls.sf.running: + break + + @classmethod + def tearDownClass(cls): + cls.sf.shutdown() + while True: + time.sleep(0.1) + if not cls.sf.running: + break + + def testSingleForm(self): + """ + Ensure that Scriptform directly shows the form if there is only one. + """ + r = requests.get("http://localhost:8002/") + self.assertIn('only_form', r.text) + + if __name__ == '__main__': logging.basicConfig(level=logging.FATAL, format='%(asctime)s:%(name)s:%(levelname)s:%(message)s', diff --git a/test/test_webapp_singleform.json b/test/test_webapp_singleform.json new file mode 100644 index 0000000..f237b7e --- /dev/null +++ b/test/test_webapp_singleform.json @@ -0,0 +1,12 @@ +{ + "title": "single form test", + "forms": [ + { + "name": "only_form", + "title": "Only form", + "description": "Only form", + "script": "test.sh", + "fields": [] + } + ] +}