diff options
author | Josh Blum | 2013-06-01 19:03:14 -0700 |
---|---|---|
committer | Josh Blum | 2013-06-01 19:03:14 -0700 |
commit | ca9738d91012c3fd04d1bd22b963a0b6a0d77f02 (patch) | |
tree | 9a526ad9c789f5b6c154c030148de67dc5f2d307 /tests/query_test.py | |
parent | bd7d2bff5fa5d23d2b7b5dfeec20c03cb97a4fb6 (diff) | |
download | sandhi-ca9738d91012c3fd04d1bd22b963a0b6a0d77f02.tar.gz sandhi-ca9738d91012c3fd04d1bd22b963a0b6a0d77f02.tar.bz2 sandhi-ca9738d91012c3fd04d1bd22b963a0b6a0d77f02.zip |
props: code cleanup and tweaks
Diffstat (limited to 'tests/query_test.py')
-rw-r--r-- | tests/query_test.py | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/tests/query_test.py b/tests/query_test.py index 1874eb2..ec8fade 100644 --- a/tests/query_test.py +++ b/tests/query_test.py @@ -4,7 +4,6 @@ import unittest import gras import numpy from demo_blocks import * -import json class MyBlock(gras.Block): def __init__(self): @@ -45,25 +44,22 @@ class QueryTest(unittest.TestCase): self.assertEqual(vec_sink.get_vector(), (0, 9, 8, 7, 6)) #query the block list - blocks_json = self.tb.query('{"path": "/blocks.json"}') - print blocks_json - blocks_python = json.loads(blocks_json) - print blocks_python - self.assertEqual(len(blocks_python['blocks']), 2) + blocks_result = self.tb.query(dict(path="/blocks.json")) + self.assertEqual(len(blocks_result['blocks']), 2) #pick a block to query below: - block_id = blocks_python['blocks'].keys()[0] + block_id = blocks_result['blocks'].keys()[0] #query the stats - stats_json = self.tb.query(str('{"path": "/stats.json", "blocks": ["%s"]}'%block_id)) - print stats_json - stats_python = json.loads(stats_json) - print stats_python - self.assertTrue('tps' in stats_python) - self.assertTrue('now' in stats_python) + stats_result = self.tb.query(dict( + path="/stats.json", + blocks=[block_id], + )) + self.assertTrue('tps' in stats_result) + self.assertTrue('now' in stats_result) #found the block we asked for - self.assertTrue(block_id in stats_python['blocks']) + self.assertTrue(block_id in stats_result['blocks']) def test_props(self): vec_source = VectorSource(numpy.uint32, [0, 9, 8, 7, 6]) @@ -72,11 +68,9 @@ class QueryTest(unittest.TestCase): self.tb.connect(vec_source, block, vec_sink) self.tb.run() - blocks_json = self.tb.query('{"path": "/blocks.json"}') - print blocks_json - blocks_python = json.loads(blocks_json) - print blocks_python - self.assertEqual(len(blocks_python['blocks']), 3) + #query the block list + blocks_result = self.tb.query(dict(path="/blocks.json")) + self.assertEqual(len(blocks_result['blocks']), 3) if __name__ == '__main__': unittest.main() |