| 1 | import unittest |
| 2 | from utils import run_in_component_init |
| 3 | |
| 4 | |
| 5 | class StreamTestCase(unittest.TestCase): |
| 6 | def setUp(self): |
| 7 | def f(comp_self): |
| 8 | return comp_self._create_trace_class() |
| 9 | |
| 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() |
| 13 | |
| 14 | def test_create_default(self): |
| 15 | stream = self._tr.create_stream(self._sc) |
| 16 | self.assertIsNone(stream.name) |
| 17 | |
| 18 | def test_name(self): |
| 19 | stream = self._tr.create_stream(self._sc, name='équidistant') |
| 20 | self.assertEqual(stream.name, 'équidistant') |
| 21 | |
| 22 | def test_invalid_name(self): |
| 23 | with self.assertRaises(TypeError): |
| 24 | self._tr.create_stream(self._sc, name=22) |
| 25 | |
| 26 | def test_stream_class(self): |
| 27 | stream = self._tr.create_stream(self._sc) |
| 28 | self.assertEqual(stream.cls, self._sc) |
| 29 | |
| 30 | def test_invalid_id(self): |
| 31 | sc = self._tc.create_stream_class(assigns_automatic_stream_id=False) |
| 32 | |
| 33 | with self.assertRaises(TypeError): |
| 34 | self._tr.create_stream(sc, id='string') |