|
|
@@ -133,7 +133,11 @@ class SolarDataWS(object): |
|
|
|
return ws |
|
|
|
|
|
|
|
async def wst_win(self, ws, data): |
|
|
|
start, stop = (int(x) / 1000 for x in data.split()) |
|
|
|
if data == 'NaN NaN': |
|
|
|
# complete data |
|
|
|
start, stop = 0, 2**32 |
|
|
|
else: |
|
|
|
start, stop = (int(x) / 1000 for x in data.split()) |
|
|
|
|
|
|
|
griddata = [ (x.meterts, x.load * 1000) for x in self._raineagle[start:stop] ] |
|
|
|
|
|
|
@@ -390,19 +394,28 @@ class Test(unittest.TestCase): |
|
|
|
relogdir.return_value = meterdata |
|
|
|
windataresp = 'this is some response' |
|
|
|
|
|
|
|
# send the initial window command |
|
|
|
await ws.send_str('win NaN NaN') |
|
|
|
|
|
|
|
# send the window command |
|
|
|
await ws.send_str('win %s %s' % (startts, |
|
|
|
endts)) |
|
|
|
|
|
|
|
async for msg in ws: |
|
|
|
r.append(msg) |
|
|
|
if len(r) == 1: |
|
|
|
if len(r) == 2: |
|
|
|
break |
|
|
|
|
|
|
|
# make sure the first call covers all of time |
|
|
|
relogdir.assert_any_call(slice(0, 2**32)) |
|
|
|
|
|
|
|
# we get passed in miliseconds from JS, but |
|
|
|
# we want seconds |
|
|
|
relogdir.assert_called_with(slice(startts / |
|
|
|
1000, endts / 1000)) |
|
|
|
|
|
|
|
|
|
|
|
# make sure that the correct data is returned |
|
|
|
self.assertEqual(r[0].type, aiohttp.WSMsgType.TEXT) |
|
|
|
obj = json.loads(r[0].data.split(' ', 1)[1]) |
|
|
|
self.assertEqual(obj, dict(production=[], |
|
|
|