def test_build_from_config3(template_sequence, template_dependencies): """Test rebuilding a sequence including twice the same template sequence """ conf = {'template_id': template_sequence, 'name': 'Template', 'template_vars': "{'b': '19'}"} seq = TemplateSequence.build_from_config(conf, template_dependencies) seq.context.channel_mapping = {'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'} conf = {'template_id': 'test', 'name': 'Template', 'template_vars': "{'b': '12'}"} seq2 = TemplateSequence.build_from_config(conf, template_dependencies) seq2.context.channel_mapping = {'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch1_A', 'Ch2': 'Ch2_A'} root = RootSequence() context = TestContext(sampling=0.5) root.context = context root.add_child_item(0, seq) root.add_child_item(0, seq2) pref = root.preferences_from_members() new = RootSequence.build_from_config(pref, template_dependencies) assert new.items[0].index == 1 seq = new.items[0] assert seq.name == 'Template' assert seq.template_id == template_sequence assert seq.template_vars == dict(b='19') assert seq.local_vars == dict(a='1.5') assert len(seq.items) == 4 assert seq.items[3].index == 5 assert seq.docs == 'Basic user comment\nff' context = seq.context assert context.template == seq assert context.logical_channels == ['A', 'B'] assert context.analogical_channel == ['Ch1', 'Ch2'] assert context.channel_mapping == {'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'} assert new.items[1].index == 2 seq = new.items[1] assert seq.name == 'Template' assert seq.template_id == 'test' assert seq.template_vars == dict(b='12') assert seq.local_vars == dict(a='1.5') assert len(seq.items) == 4 assert seq.items[3].index == 5 assert seq.docs == 'Basic user comment\nff' context = seq.context assert context.template == seq assert context.logical_channels == ['A', 'B'] assert context.analogical_channels == ['Ch1', 'Ch2'] assert context.channel_mapping == {'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch1_A', 'Ch2': 'Ch2_A'}
def test_build_from_config1(template_sequence, template_dependencies): """ Test building a template sequence from only the template file. No information is knwon about channel mapping of template_vars values """ conf = { 'template_id': template_sequence, 'name': 'Template', 'template_vars': "{'b': '19', 'c': ''}" } seq = TemplateSequence.build_from_config(conf, template_dependencies) assert seq.name == 'Template' assert seq.template_id == template_sequence assert seq.template_vars == dict(b='19') assert seq.local_vars == dict(a='1.5') assert len(seq.items) == 4 assert seq.items[3].index == 5 assert seq.docs == 'Basic user comment\nff' context = seq.context assert context.template is seq assert context.logical_channels == ['A', 'B'] assert context.analogical_channels == ['Ch1', 'Ch2'] assert context.channel_mapping == {'A': '', 'B': '', 'Ch1': '', 'Ch2': ''}
def test_build_from_config2(template_sequence, template_dependencies): """ Test rebuilding a sequence including a template sequence. Channel mapping of template_vars values are known. """ conf = { 'template_id': 'test', 'name': 'Template', 'template_vars': "{'b': '25'}" } seq = TemplateSequence.build_from_config(conf, template_dependencies) seq.context.channel_mapping = { 'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A' } root = RootSequence() context = TestContext(sampling=0.5) root.context = context root.add_child_item(0, seq) pref = root.preferences_from_members() new = RootSequence.build_from_config(pref, template_dependencies) assert new.items[0].index == 1 seq = new.items[0] assert seq.name == 'Template' assert seq.template_id == template_sequence assert seq.template_vars == dict(b='25') assert seq.local_vars == dict(a='1.5') assert len(seq.items) == 4 assert seq.items[3].index == 5 assert seq.docs == 'Basic user comment\nff' context = seq.context assert context.template is seq assert context.logical_channels == ['A', 'B'] assert context.analogical_channels == ['Ch1', 'Ch2'] assert context.channel_mapping == { 'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A' }
def root_with_template(template_sequence, template_dependencies): """Build a root using the template sequence. """ root = RootSequence() root.context = TestContext(sampling=0.5) conf = {'template_id': template_sequence, 'name': 'Template', 'template_vars': "{'b': '19'}"} seq = TemplateSequence.build_from_config(conf, template_dependencies) seq.context.channel_mapping = {'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'} seq.def_1 = '1.0' seq.def_2 = '20.0' root.add_child_item(0, seq) return root
def root_with_template(template_sequence, template_dependencies): """Build a root using the template sequence. """ root = RootSequence() root.context = TestContext(sampling=0.5) conf = { 'template_id': template_sequence, 'name': 'Template', 'template_vars': "{'b': '19'}" } seq = TemplateSequence.build_from_config(conf, template_dependencies) seq.context.channel_mapping = { 'A': 'Ch1_L', 'B': 'Ch2_L', 'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A' } seq.def_1 = '1.0' seq.def_2 = '20.0' root.add_child_item(0, seq) return root
def test_build_from_config1(template_sequence, template_dependencies): """ Test building a template sequence from only the template file. No information is knwon about channel mapping of template_vars values """ conf = {'template_id': template_sequence, 'name': 'Template', 'template_vars': "{'b': '19', 'c': ''}"} seq = TemplateSequence.build_from_config(conf, template_dependencies) assert seq.name == 'Template' assert seq.template_id == template_sequence assert seq.template_vars == dict(b='19') assert seq.local_vars == dict(a='1.5') assert len(seq.items) == 4 assert seq.items[3].index == 5 assert seq.docs == 'Basic user comment\nff' context = seq.context assert context.template is seq assert context.logical_channels == ['A', 'B'] assert context.analogical_channels == ['Ch1', 'Ch2'] assert context.channel_mapping == {'A': '', 'B': '', 'Ch1': '', 'Ch2': ''}