def setUp(self): try: self._my_class = InventoryServer() except Exception as excp: pass try: self._my_app = webtest.TestApp(application) except: pass
from inventoryserver.server import SpecialOrders # cherrypy.config.update({'environment': 'embedded'}) if cherrypy.__version__.startswith("3.0") and cherrypy.engine.state == 0: cherrypy.engine.start(blocking=False) atexit.register(cherrypy.engine.stop) class Root(object): def index(self): return "Hello World!" index.exposed = True root = InventoryServer() root.admin = Admin() root.staffing = Staffing() root.notes = Noteboard() root.register = Register() root.specialorder = SpecialOrders() cherrypy_local_config_file = configuration.get("cherrypy_local_config_file") application = cherrypy.Application( root, script_name=None, config=cherrypy_local_config_file ) if __name__ == "__main__": cherrypy.quickstart(root, "/", cherrypy_local_config_file)
"""this function name doesn't matter much, it can start with `test`, but we're going to rename it dynamically below""" reportURLstring = "/report?reportname=" + reportItem.metadata["action"] response = self._my_app.get(reportURLstring) code, error = tidylib.tidy_document(response.body, options={ "show-errors": 1, "show-warnings": 0 }) self.assertFalse(error, "%s did not return valid html page" % reportURLstring) return dynamic_test_method for reportItem in InventoryServer().reportlist: dynamic_method = create_dynamic_method(reportItem) dynamic_method.__name__ = "test_%s" % reportItem.metadata["name"].replace( " ", "_") setattr(Test_InventoryServer, dynamic_method.__name__, dynamic_method) """ class Test_MenuData def test_getMenuData def test_setMenuData def test_jsonify_tool_callback class Test_Staffing def test_calendar class Test_Admin def test_print_label def test_search_id def test_select_item_for_isbn_search