-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MockDevice support for /data and /df (#25)
* Add support for api/v1/data/ and api/v1/df/ APIs. Mock is currently always returning the same data regardless of stream slug. * Build IOTileProjectSlug if needed when constructing an IOTileVariableSlug * Remove hard coded filter on /data and /df Now properly getting filter argument from Request object * Fix changelog
- Loading branch information
Showing
7 changed files
with
213 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
tests/data/watermeter/s--0000-0077--0000-0000-0000-00d2--5001.raw.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
[ | ||
{ | ||
"id": 577632, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T20:06:02Z", | ||
"int_value": 96, | ||
"value": 36339.936, | ||
"streamer_local_id": 9777, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577636, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T20:16:02Z", | ||
"int_value": 100, | ||
"value": 37854.1, | ||
"streamer_local_id": 9779, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577640, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T20:26:02Z", | ||
"int_value": 101, | ||
"value": 38232.641, | ||
"streamer_local_id": 9781, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577644, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T20:36:02Z", | ||
"int_value": 100, | ||
"value": 37854.1, | ||
"streamer_local_id": 9786, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577648, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T20:46:02Z", | ||
"int_value": 101, | ||
"value": 38232.641, | ||
"streamer_local_id": 9788, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577652, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T20:56:02Z", | ||
"int_value": 100, | ||
"value": 37854.1, | ||
"streamer_local_id": 9790, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577656, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T21:06:02Z", | ||
"int_value": 100, | ||
"value": 37854.1, | ||
"streamer_local_id": 9792, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577660, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T21:16:02Z", | ||
"int_value": 101, | ||
"value": 38232.641, | ||
"streamer_local_id": 9794, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
}, | ||
{ | ||
"id": 577664, | ||
"stream": "s--0000-0077--0000-0000-0000-00d2--5001", | ||
"project": "p--0000-0077", | ||
"device": "d--0000-0000-0000-00d2", | ||
"variable": "v--0000-0077--5001", | ||
"type": "ITR", | ||
"device_timestamp": null, | ||
"timestamp": "2017-04-12T21:26:02Z", | ||
"int_value": 100, | ||
"value": 37854.1, | ||
"streamer_local_id": 9796, | ||
"dirty_ts": false, | ||
"status": "unk" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,41 @@ def test_data_access(water_meter): | |
api.vartype('water-meter-volume').get() | ||
|
||
|
||
def test_data_stream(water_meter): | ||
"""Make sure we can load and access data.""" | ||
|
||
domain, _cloud = water_meter | ||
|
||
api = Api(domain=domain, verify=False) | ||
api.login('test', '[email protected]') | ||
|
||
data = api.data.get(filter='s--0000-0077--0000-0000-0000-00d2--5001') | ||
|
||
assert data['count'] == 9 | ||
first = data['results'][0] | ||
assert first['project'] == 'p--0000-0077' | ||
assert first['device'] == 'd--0000-0000-0000-00d2' | ||
assert first['stream'] == 's--0000-0077--0000-0000-0000-00d2--5001' | ||
assert first['value'] == 36339.936 | ||
assert first['int_value'] == 96 | ||
|
||
|
||
def test_data_frame(water_meter): | ||
"""Make sure we can load and access data.""" | ||
|
||
domain, _cloud = water_meter | ||
|
||
api = Api(domain=domain, verify=False) | ||
api.login('test', '[email protected]') | ||
|
||
data = api.df.get(filter='s--0000-0077--0000-0000-0000-00d2--5001') | ||
|
||
first = data[0] | ||
assert first['stream_slug'] == 's--0000-0077--0000-0000-0000-00d2--5001' | ||
assert first['value'] == 36339.936 | ||
assert first['row'] == '2017-04-12T20:06:02Z' | ||
|
||
|
||
def test_quick_add_functionality(mock_cloud_private_nossl): | ||
"""Make sure quick add functions work.""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = '0.8.2' | ||
version = '0.8.3' |