def test_get_childs_tree(): # test straight track = ss.Track(id='B4Ch1', project=ss.Project(MASTER_PROJ_NAME)) tree = track.get_childs_tree() assert tree[(1, 0)].track.name == 'B4Ch1B1' assert tree[(3, 0)].track.name == 'B4Ch1B3' # test recursive track = ss.Track(id='B4', project=ss.Project(MASTER_PROJ_NAME)) tree = track.get_childs_tree() assert tree[(0, 1)].track.name == 'B4Ch1' assert tree[(0, 1)].childs[(1, 0)].track.name == 'B4Ch1B1'
def test_master_out_track(): m_pr = ss.Project(MASTER_PROJ_NAME, 'localhost') s_pr = ss.SlaveProject(SLAVE_PROJECT_NAME, 'localhost') m_pr.make_current_project() # m_tr = rpr.Track(id='out', project=m_pr) # print(s_pr.__module__, s_pr.__qualname__) # with s_pr.make_current_project(): s_tr = ss.SlaveInTrack(id='in', project=s_pr) o_track = ss.MasterOutTrack(id='out', project=m_pr, target=s_tr) assert s_tr.project.last_ip == 'localhost' o_childs = o_track.childs assert rpr.Track(id='no_midi_send', project=ss.Project(MASTER_PROJ_NAME)).id not in o_childs assert len(o_childs) == 18 matched = o_track.match_childs() m_id = rpr.Track(id='B4', project=m_pr).id assert matched[m_id].target.s_project.last_ip == 'localhost' # with s_pr.make_current_project(): # print(matched[m_id].target.name) assert matched[m_id].target == rpr.Track(id='B4', project=s_pr) m_id = rpr.Track(id='B3Ch4', project=m_pr).id # with s_pr.make_current_project(): assert matched[m_id].target == rpr.Track(id='B3Ch4', project=s_pr) m_id = rpr.Track(id='B4Ch1B1', project=m_pr).id # with s_pr.make_current_project(): assert matched[m_id].target == rpr.Track(id='B4Ch1', project=s_pr) m_id = rpr.Track(id='B2Ch1B1', project=m_pr).id # with s_pr.make_current_project(): assert matched[m_id].target == rpr.Track(id='B2Ch1B1', project=s_pr) # recarm master_names = ('B1', 'B3Ch4', 'B4Ch1B1') slave_names = ('B1', 'B3Ch4', 'B4Ch1') # with m_pr.make_current_project(): for name in master_names: tr = ss.Track(id=name, project=m_pr) tr.recarm = True o_track.sync_recarm() # with s_pr.make_current_project(): tr = ss.Track(id='B4', project=s_pr) assert tr.recarm == False for name in slave_names: tr = ss.Track(id=name, project=s_pr) assert tr.recarm == True # with m_pr.make_current_project(): for name in master_names: tr = ss.Track(id=name, project=m_pr) tr.recarm = False o_track.sync_recarm() # with s_pr.make_current_project(): tr = ss.Track(id='B4', project=s_pr) assert tr.recarm == False for name in slave_names: tr = ss.Track(id=name, project=s_pr) assert tr.recarm == False
def test_pickled(request): tr = ss.Track('slave1', ss.Project('test_master_persistent')) old_id = tr.id dump = pickle.dumps(tr) assert str(dump).find('_guid') loaded = ty.cast(ss.Track, pickle.loads(dump)) assert loaded.GUID == tr.GUID c_id = request.config.cache.get('test_pickled/id', None) if c_id is None: request.config.cache.set('test_pickled/id', old_id) else: old_id = c_id assert old_id != loaded.id assert loaded.id == tr.id
def track(id: str) -> ss.Track: return ss.Track(id=id, project=ss.Project(MASTER_PROJ_NAME))
def test_childs_tree(): tracks_out = { 'B1Chall': ss.Track('B1Chall'), 'B2Chall': ss.Track('B2Chall'), 'B3Chall': ss.Track('B3Chall', buses_packed=True), 'B3ChallB1Ch1': ss.Track('B3ChallB1Ch1'), 'B3ChallB1Ch2': ss.Track('B3ChallB1Ch2'), 'B4Chall': ss.Track('B4Chall', buses_packed=True), 'B4ChallB2Ch1': ss.Track('B4ChallB2Ch1'), 'B4ChallB2Ch2': ss.Track('B4ChallB2Ch2'), 'B5Chall': ss.Track('B5Chall', buses_packed=True), 'B5ChallB1Ch1': ss.Track('B5ChallB1Ch1'), 'B5ChallB2Ch1': ss.Track('B5ChallB2Ch1'), 'B5ChallB2Ch1B1Chall': ss.Track('B5ChallB2Ch1B1Chall'), 'B5ChallB2Ch1B2Chall': ss.Track('B5ChallB2Ch1B2Chall'), } tracks_in = { 'B1Chall': ss.Track('B1Chall'), 'B2Chall': ss.Track('B2Chall'), 'B3Chall': ss.Track('B3Chall', buses_unpacked=True), 'B3ChallB1Ch1': ss.Track('B3ChallB1Ch1'), 'B3ChallB1Ch2': ss.Track('B3ChallB1Ch2'), 'B4Chall': ss.Track('B4Chall'), 'B5Chall': ss.Track('B5Chall', buses_unpacked=True), 'B5ChallB2Ch1': ss.Track('B5ChallB2Ch1'), 'B5ChallB2Ch2': ss.Track('B5ChallB2Ch2'), } assert tracks_out['B1Chall'].id == "B1Chall" tree_out = { ss.ChildAddress(1, 0): ss.Child(track=tracks_out['B1Chall']), ss.ChildAddress(2, 0): ss.Child(track=tracks_out['B2Chall']), ss.ChildAddress(3, 0): ss.Child(track=tracks_out['B3Chall'], childs={ ss.ChildAddress(1, 1): ss.Child(tracks_out['B3ChallB1Ch1']), ss.ChildAddress(1, 2): ss.Child(tracks_out['B3ChallB1Ch2']) }), ss.ChildAddress(4, 0): ss.Child(track=tracks_out['B4Chall'], childs={ ss.ChildAddress(2, 1): ss.Child(tracks_out['B4ChallB2Ch1']), ss.ChildAddress(2, 2): ss.Child(tracks_out['B4ChallB2Ch2']) }), ss.ChildAddress(5, 0): ss.Child(track=tracks_out['B5Chall'], childs={ ss.ChildAddress(1, 1): ss.Child(tracks_out['B5ChallB1Ch1']), ss.ChildAddress(2, 1): ss.Child(tracks_out['B5ChallB2Ch1'], childs={ ss.ChildAddress(1, 0): ss.Child(tracks_out['B5ChallB2Ch1B1Chall']), ss.ChildAddress(2, 0): ss.Child(tracks_out['B5ChallB2Ch1B2Chall']), }), }), } tree_in = { ss.ChildAddress(1, 0): ss.Child(track=tracks_in['B1Chall']), ss.ChildAddress(2, 0): ss.Child(track=tracks_in['B2Chall']), ss.ChildAddress(3, 0): ss.Child(track=tracks_in['B3Chall'], childs={ ss.ChildAddress(1, 1): ss.Child(tracks_in['B3ChallB1Ch1']), ss.ChildAddress(1, 2): ss.Child(tracks_in['B3ChallB1Ch2']) }), ss.ChildAddress(4, 0): ss.Child(track=tracks_in['B4Chall']), ss.ChildAddress(5, 0): ss.Child(track=tracks_in['B5Chall'], childs={ ss.ChildAddress(2, 1): ss.Child(tracks_in['B5ChallB2Ch1']), ss.ChildAddress(2, 2): ss.Child(tracks_in['B5ChallB2Ch2']) }), } init_target = ss.Track('slave_in') # tracks matched primary\secondary t_m_p, t_m_s = ss.Child.match(tree_out, tree_in, init_target) # simple case assert t_m_p['B1Chall'].target is tracks_in['B1Chall'] # complex case assert t_m_s['B4ChallB2Ch2'].target is tracks_in['B4Chall'] # too complex case assert t_m_s['B4ChallB2Ch1'].target is tracks_in['B4Chall'] assert t_m_s['B4ChallB2Ch2'].target is tracks_in['B4Chall'] assert t_m_s['B5ChallB2Ch1B2Chall'].target is tracks_in['B5ChallB2Ch1']