7 class QueryExecutorTestCase(unittest
.TestCase
):
9 class MySink(bt2
._UserSinkComponent
):
14 def _query(cls
, query_exec
, obj
, params
):
24 'array': ['coucou', 23, None],
33 res
= bt2
.QueryExecutor().query(MySink
, 'obj', params
)
34 self
.assertEqual(query_params
, params
)
35 self
.assertEqual(res
, {
41 def test_query_params_none(self
):
42 class MySink(bt2
._UserSinkComponent
):
47 def _query(cls
, query_exec
, obj
, params
):
52 res
= bt2
.QueryExecutor().query(MySink
, 'obj', None)
53 self
.assertEqual(query_params
, None)
56 def test_query_gen_error(self
):
57 class MySink(bt2
._UserSinkComponent
):
62 def _query(cls
, query_exec
, obj
, params
):
65 with self
.assertRaises(bt2
.Error
):
66 res
= bt2
.QueryExecutor().query(MySink
, 'obj', [17, 23])
68 def test_query_invalid_object(self
):
69 class MySink(bt2
._UserSinkComponent
):
74 def _query(cls
, query_exec
, obj
, params
):
75 raise bt2
.InvalidQueryObject
77 with self
.assertRaises(bt2
.InvalidQueryObject
):
78 res
= bt2
.QueryExecutor().query(MySink
, 'obj', [17, 23])
80 def test_query_invalid_params(self
):
81 class MySink(bt2
._UserSinkComponent
):
86 def _query(cls
, query_exec
, obj
, params
):
87 raise bt2
.InvalidQueryParams
89 with self
.assertRaises(bt2
.InvalidQueryParams
):
90 res
= bt2
.QueryExecutor().query(MySink
, 'obj', [17, 23])
92 def test_query_try_again(self
):
93 class MySink(bt2
._UserSinkComponent
):
98 def _query(cls
, query_exec
, obj
, params
):
101 with self
.assertRaises(bt2
.TryAgain
):
102 res
= bt2
.QueryExecutor().query(MySink
, 'obj', [17, 23])
104 def test_cancel_no_query(self
):
105 query_exec
= bt2
.QueryExecutor()
106 self
.assertFalse(query_exec
.is_canceled
)
108 self
.assertTrue(query_exec
.is_canceled
)
110 def test_query_canceled(self
):
111 class MySink(bt2
._UserSinkComponent
):
116 def _query(cls
, query_exec
, obj
, params
):
119 query_exec
= bt2
.QueryExecutor()
122 with self
.assertRaises(bt2
.QueryExecutorCanceled
):
123 res
= query_exec
.query(MySink
, 'obj', [17, 23])
This page took 0.032062 seconds and 4 git commands to generate.