def setUp(self): class TestHub(Hub): def getData(self): pass class TestHub2(Hub): pass Hub.initHubsInspection()
def setUp(self): #Constucting hubs for testing class TestHub(Hub): def getData(self): pass class TestHub2(Hub): pass Hub.initHubsInspection()
def test_JAVACreation(self): path = "onTest" Hub.constructJAVAFile("test", path) self.assertTrue(os.path.exists(os.path.join(path, JAVAFileGenerator.SERVER_FILE_NAME))) self.assertTrue(os.path.exists(os.path.join(path, JAVAFileGenerator.CLIENT_PACKAGE_NAME))) for f in listdir(path): fullPath = os.path.join(path, f) os.remove(fullPath) if os.path.isfile(fullPath) else shutil.rmtree(fullPath) os.removedirs(path)
def test_JSCreation(self): Hub.constructJSFile() self.assertTrue(os.path.exists(JSClientFileGenerator.FILE_NAME)) os.remove(JSClientFileGenerator.FILE_NAME) otherPath = "onTest" fullPath = os.path.join(otherPath, JSClientFileGenerator.FILE_NAME) Hub.constructJSFile(otherPath) self.assertTrue(os.path.exists(fullPath)) os.remove(fullPath) os.removedirs("onTest")
def test_PythonCreation(self): Hub.constructPythonFile() self.assertTrue(os.path.exists(PythonClientFileGenerator.FILE_NAME)) self.assertTrue(os.path.exists("__init__.py"), "Check if python package is created") os.remove(PythonClientFileGenerator.FILE_NAME) otherPath = "onTest" fullPath = os.path.join(otherPath, PythonClientFileGenerator.FILE_NAME) packageFilePath = os.path.join(otherPath, "__init__.py") Hub.constructPythonFile(otherPath) self.assertTrue(os.path.exists(fullPath)) self.assertTrue(os.path.exists(packageFilePath), "Check if python package is created") os.remove(fullPath) os.remove(packageFilePath) os.removedirs("onTest")
import importlib import json import logging import logging.config from WSHubsAPI.ConnectionHandlers.WS4Py import ClientHandler from wsgiref.simple_server import make_server from ws4py.server.wsgirefserver import WSGIServer, WebSocketWSGIRequestHandler from WSHubsAPI.Hub import Hub from ws4py.server.wsgiutils import WebSocketWSGIApplication logging.config.dictConfig(json.load(open('logging.json'))) log = logging.getLogger(__name__) if __name__ == '__main__': importlib.import_module("ChatHub") # necessary to add this import for code inspection # construct the necessary client files in the specified path Hub.constructPythonFile("../Clients/_static") Hub.constructJSFile("../Clients/_static") # Hub.constructJAVAFile("tornado.WSHubsApi", "C:/Users/Jorge/Desktop/tornado/src/tornado/WSHubsApi") server = make_server('127.0.0.1', 8888, server_class=WSGIServer, handler_class=WebSocketWSGIRequestHandler, app=WebSocketWSGIApplication(handler_cls=ClientHandler)) server.initialize_websockets_manager() log.debug("starting...") target = server.serve_forever()
import importlib import os import logging import logging.config import json from tornado import web, ioloop from WSHubsAPI.Hub import Hub from WSHubsAPI.ConnectionHandlers.Tornado import ClientHandler logging.config.dictConfig(json.load(open('logging.json'))) log = logging.getLogger(__name__) settings = {"static_path": os.path.join(os.path.dirname(__file__), "../Clients/_static"), } app = web.Application([ (r'/(.*)', ClientHandler), ], **settings) if __name__ == '__main__': importlib.import_module("ChatHub") # necessary to add this import for code inspection Hub.constructJSFile(settings["static_path"]) Hub.constructPythonFile(settings["static_path"]) log.debug("starting...") app.listen(8888) ioloop.IOLoop.instance().start()