|
|
@@ -71,13 +71,11 @@ class SolarDataWS(object): |
|
|
|
|
|
|
|
def get_routes(self): |
|
|
|
return [ |
|
|
|
web.get('/ws', self.websocket_handler), |
|
|
|
web.get('/solar.ws', self.websocket_handler), |
|
|
|
] |
|
|
|
|
|
|
|
# XXX - how to configure this properly |
|
|
|
sdws = SolarDataWS('./raineagle.') |
|
|
|
|
|
|
|
def getapp(sdws): |
|
|
|
def getapp(argv): |
|
|
|
sdws = SolarDataWS(argv[0]) |
|
|
|
app = web.Application() |
|
|
|
app.add_routes(sdws.get_routes()) |
|
|
|
p = os.path.join(os.path.dirname(__file__), '..', 'root') |
|
|
@@ -91,7 +89,9 @@ def getapp(sdws): |
|
|
|
|
|
|
|
return app |
|
|
|
|
|
|
|
app = getapp(sdws) |
|
|
|
def main(): |
|
|
|
app = getapp(sys.argv[1:]) |
|
|
|
web.run_app(app) |
|
|
|
|
|
|
|
# https://stackoverflow.com/questions/23033939/how-to-test-python-3-4-asyncio-code |
|
|
|
# Slightly modified to timeout and to print trace back when canceled. |
|
|
@@ -124,9 +124,8 @@ class Test(unittest.TestCase): |
|
|
|
|
|
|
|
self.rootdir = os.path.join(os.path.dirname(__file__), '..', 'root') |
|
|
|
os.chdir(self.tempdir) |
|
|
|
sdws = SolarDataWS(os.path.join(self.tempdir, 'raineagle')) |
|
|
|
|
|
|
|
app = getapp(sdws) |
|
|
|
app = getapp([ os.path.join(self.tempdir, 'raineagle') ]) |
|
|
|
self._app = app |
|
|
|
|
|
|
|
# launch the server |
|
|
@@ -173,7 +172,7 @@ class Test(unittest.TestCase): |
|
|
|
r = [] |
|
|
|
try: |
|
|
|
async with aiohttp.ClientSession() as session, \ |
|
|
|
session.ws_connect(self.makeurl('ws')) as ws: |
|
|
|
session.ws_connect(self.makeurl('solar.ws')) as ws: |
|
|
|
async for msg in ws: |
|
|
|
r.append(msg) |
|
|
|
if len(r) == 2: |
|
|
|