summaryrefslogtreecommitdiff
path: root/tests/query_test.py
blob: e93b5d6a3bfa38f7fe91612cb6ca471c040c30ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.

import unittest
import gras
import numpy
from demo_blocks import *
import json

class QueryTest(unittest.TestCase):

    def setUp(self):
        self.tb = gras.TopBlock()

    def tearDown(self):
        self.tb = None

    def test_simple(self):
        vec_source = VectorSource(numpy.uint32, [0, 9, 8, 7, 6])
        vec_sink = VectorSink(numpy.uint32)

        self.tb.connect(vec_source, vec_sink)
        self.tb.run()

        self.assertEqual(vec_sink.get_vector(), (0, 9, 8, 7, 6))

        blocks_json = self.tb.query("<args><path>/blocks.json</path></args>")
        print blocks_json
        json.loads(blocks_json)

        stats_json = self.tb.query("<args><path>/stats.json</path></args>")
        print stats_json
        json.loads(stats_json)

if __name__ == '__main__':
    unittest.main()