def test_get_subset_for_channels(self): subsetted = DummyWaveform(defined_channels={'a'}) with mock.patch.object( DummyWaveform, 'get_subset_for_channels', mock.Mock(return_value=subsetted)) as get_subset_for_channels: inner_wf = DummyWaveform(defined_channels={'a', 'b', 'c'}) subset_wf = SubsetWaveform(inner_wf, {'a', 'c'}) actual_subsetted = subset_wf.get_subset_for_channels({'a'}) get_subset_for_channels.assert_called_once_with({'a'}) self.assertIs(subsetted, actual_subsetted)
def test_unsafe_sample(self): """Test perfect forwarding""" time = {'time'} output = {'output'} expected_data = {'data'} with mock.patch.object( DummyWaveform, 'unsafe_sample', mock.Mock(return_value=expected_data)) as unsafe_sample: inner_wf = DummyWaveform(defined_channels={'a', 'b', 'c'}) subset_wf = SubsetWaveform(inner_wf, {'a', 'c'}) actual_data = subset_wf.unsafe_sample('g', time, output) self.assertIs(expected_data, actual_data) unsafe_sample.assert_called_once_with('g', time, output)
def test_unsafe_get_subset_for_channels(self): lhs = DummyWaveform(duration=1.5, defined_channels={'a', 'b', 'c'}) rhs = DummyWaveform(duration=1.5, defined_channels={'a', 'b', 'd'}) arith = ArithmeticWaveform(lhs, '-', rhs) self.assertEqual(SubsetWaveform(arith, {'a', 'c'}), arith.unsafe_get_subset_for_channels({'a', 'c'}))
def test_simple_properties(self): inner_wf = DummyWaveform(duration=1.5, defined_channels={'a', 'b', 'c'}) subset_wf = SubsetWaveform(inner_wf, {'a', 'c'}) self.assertIs(subset_wf.inner_waveform, inner_wf) self.assertEqual(subset_wf.compare_key, (frozenset(['a', 'c']), inner_wf)) self.assertIs(subset_wf.duration, inner_wf.duration) self.assertEqual(subset_wf.defined_channels, {'a', 'c'})