def test_gleb2_pch__unequal(self): gleb_2_pch = get_test_resource('Gleb2.pch2') expected_modules_correct = [ Module(self.data, Location.VOICE_AREA, 4, 1), Module(self.data, Location.VOICE_AREA, 96, 2, [2]) ] expected_modules = [ Module(self.data, Location.VOICE_AREA, 4, 1), Module(self.data, Location.VOICE_AREA, 100, 2) ] expected_cables = [ Cable(Location.VOICE_AREA, CableType.IN_TO_IN, CableColor.WHITE, 1, 0, 141, 1) ] parsed = parse_pch2(self.data, gleb_2_pch, convert_in2in=False) self.assertTrue(parsed.modules == expected_modules_correct) self.assertFalse(parsed.modules == expected_modules) self.assertFalse(parsed.cables == expected_cables)
def test_gleb2_pch(self): gleb_2_pch = get_test_resource('Gleb2.pch2') expected_modules = [ Module(self.data, Location.VOICE_AREA, 4, 1), Module(self.data, Location.VOICE_AREA, 96, 2, [2]) ] expected_cables = [ Cable(Location.VOICE_AREA, CableType.IN_TO_IN, CableColor.WHITE, 1, 1, 1, 0) ] expected_mod_params = [ ModuleParameters(Location.VOICE_AREA, 1, 3, [0, 1, 0]), ModuleParameters(Location.VOICE_AREA, 2, 5, [127, 127, 0, 2, 0]) ] parsed = parse_pch2(self.data, gleb_2_pch, convert_in2in=False) self.assertSequenceEqual(parsed.modules, expected_modules) self.assertSequenceEqual(parsed.cables, expected_cables) self.assertSequenceEqual(parsed.mod_params, expected_mod_params)
def test_r2b_b2r(self): p = parse_pch2(self.data, self.r2b_b2r_fn) zak = ZakSpace() udos = zak.connect_patch(p) in2, envh, out2, a2k, k2a = sorted(udos, key=lambda x: x.mod.id) # sends a self.assertSequenceEqual(in2.outlets, [7, 0]) # a -> k self.assertSequenceEqual(a2k.inlets, [7]) self.assertSequenceEqual(a2k.outlets, [7]) # receives k self.assertSequenceEqual(envh.inlets, [1, 7, 1]) # sends k self.assertSequenceEqual(envh.outlets, [0, 8]) # k -> a self.assertSequenceEqual(k2a.inlets, [8]) self.assertSequenceEqual(k2a.outlets, [8]) # receives a self.assertSequenceEqual(out2.inlets, [8, 1]) csd = Csd(p, zak, udos) print(csd.get_code())
def validate_udo(type_id: int, io=sys.stdout, print_action=True): if print_action: print("checking module type '{id}' ({id}.txt)".format(id=type_id), file=io) pch2_files = [ get_test_resource(s) for s in ['test_all_modules_1.pch2', 'test_all_modules_2.pch2'] ] data, mod, patch = ProjectData(), None, None for p in map(lambda x: parse_pch2(data, x), pch2_files): for m in p.modules: if m.type == type_id: mod, patch = m, p break if mod is not None: if print_action: print('module name: {}'.format(mod.type_name), file=io) udo = UdoTemplate(mod) v = UdoTemplateValidation(data, udo) v.print_errors(io) return v.is_valid(with_todos=True) else: print("error: unknown module type '{}'".format(type_id), file=io) return False
def test_in2in__all_cables_from_the_first_module(self): pch2 = get_test_resource('test_in2in.pch2') patch = parse_pch2(self.data, pch2) patch.cables = [transform_in2in_cables(patch, c) for c in patch.cables] for c in patch.cables: self.assertEqual(c.module_from, 1)
def setUp(self): self.data = ProjectData() self.poly_mix2 = parse_pch2(self.data, get_test_resource('test_poly_mix2.pch2'))
def test_modes__LfoC(self): pch2 = get_test_resource('test_modes_LfoC.pch2') patch = parse_pch2(self.data, pch2) p_modes = [m.modes for m in patch.modules] self.assertSequenceEqual(p_modes, [[0], [1], [2], [3], [4], [5], [6], [7]])