def run_skink_server(): root_dir = abspath(dirname(__file__)) server = Server(root_dir=root_dir) server.build_dir = join(root_dir, "ci_tmp") server.subscribe('on_user_authentication_failed', on_user_authentication_failed_handler) server.context.current_project = None server.context.current_command = None server.context.current_log = "" server.context.build_queue = Queue.deque() server.context.projects_being_built = Queue.deque() builder = BuilderPlugin(cherrypy.engine, server) builder.subscribe() monitor = MonitorPlugin(cherrypy.engine, server) monitor.subscribe() try: server.start("config.ini", non_block=True) for plugin in SkinkPlugin.all(): config = server.context.settings.config if config.has_section(plugin.__name__) and \ config.get(plugin.__name__, "enabled") == "True": cherrypy.log('Plugin %s enabled!' % plugin.__name__, 'PLUGINS') instance = plugin(server) cherrypy.engine.block() except KeyboardInterrupt: server.stop()
def test_server_can_start(): clear() server = Server(root_dir=root_dir) try: server.start(config_path=config_path, non_block=True) assert server.status == ServerStatus.Started finally: server.stop()
def test_server_responds_for_healthcheck_action(): clear() class TestController(Controller): pass server = Server(root_dir=root_dir) try: server.start(config_path=config_path, non_block=True) status_code, content = HttpClient.get(join(server.context.settings.Ion.baseurl, "healthcheck")) assert status_code == 200 assert content == "WORKING" finally: server.stop()
class ServerHelper (object): def __init__(self, root_path, config_path): self.server = Server(root_path) self.server.start(config_path, non_block=True) while not self.server.status == ServerStatus.Started: time.sleep(0.5) def stop(self): self.server.stop() self.server = None def ctrl(self, controller): _ctrl = controller() _ctrl.server = self.server return _ctrl
def test_server_responds_for_controller_action(): clear() class TestController(Controller): @route("/") def SomeAction(self): return "Hello World" server = Server(root_dir=root_dir) try: server.start(config_path=config_path, non_block=True) status_code, content = HttpClient.get(server.context.settings.Ion.baseurl) assert status_code == 200 assert content == "Hello World" finally: server.stop()