Commit | Line | Data |
---|---|---|
9cf643d1 | 1 | import unittest |
af4bbfc7 | 2 | from utils import run_in_component_init |
9cf643d1 PP |
3 | |
4 | ||
5 | class StreamTestCase(unittest.TestCase): | |
6 | def setUp(self): | |
af4bbfc7 SM |
7 | def f(comp_self): |
8 | return comp_self._create_trace_class() | |
9cf643d1 | 9 | |
af4bbfc7 SM |
10 | self._tc = run_in_component_init(f) |
11 | self._sc = self._tc.create_stream_class(assigns_automatic_stream_id=True) | |
12 | self._tr = self._tc() | |
811644b8 | 13 | |
af4bbfc7 SM |
14 | def test_create_default(self): |
15 | stream = self._tr.create_stream(self._sc) | |
16 | self.assertIsNone(stream.name) | |
9cf643d1 | 17 | |
af4bbfc7 SM |
18 | def test_name(self): |
19 | stream = self._tr.create_stream(self._sc, name='équidistant') | |
20 | self.assertEqual(stream.name, 'équidistant') | |
9cf643d1 | 21 | |
af4bbfc7 SM |
22 | def test_invalid_name(self): |
23 | with self.assertRaises(TypeError): | |
24 | self._tr.create_stream(self._sc, name=22) | |
9cf643d1 | 25 | |
af4bbfc7 SM |
26 | def test_stream_class(self): |
27 | stream = self._tr.create_stream(self._sc) | |
28 | self.assertEqual(stream.stream_class, self._sc) | |
9cf643d1 | 29 | |
af4bbfc7 SM |
30 | def test_invalid_id(self): |
31 | sc = self._tc.create_stream_class(assigns_automatic_stream_id=False) | |
9cf643d1 | 32 | |
af4bbfc7 SM |
33 | with self.assertRaises(TypeError): |
34 | self._tr.create_stream(sc, id='string') |