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_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_sess_hosts(): my_sess = sess.Session(ss.Project('test_master')) my_sess._hosts.add(ss.Host('192.168.3.45')) assert my_sess._hosts == set( [ss.Host('192.168.3.45'), ss.Host('localhost')]) my_sess.hosts_check() assert ss.Host('192.168.3.45') not in my_sess._hosts
def test_slaves_handling(): my_sess = sess.Session(ss.Project('test_master_persistent')) slave1 = ss.projects.SlaveProject('test_slave') slave2 = ss.projects.SlaveProject('test_slave2') m_pr = my_sess.master sl1_tr, sl2_tr = [ ss.tracks.Track(name, m_pr) for name in ('slave1', 'slave2') ] # my_sess.slaves = {sl1_tr.GUID: slave1, sl2_tr.GUID: slave2} slaves_keys = tuple(my_sess.slaves.keys()) assert slaves_keys == (sl1_tr.GUID, sl2_tr.GUID)
def test_slave_state_tracking(): m_sess = sess.Session(ss.Project('test_master_persistent')) slave1 = ss.projects.SlaveProject('test_slave') slave2 = ss.projects.SlaveProject('test_slave2') assert m_sess.slaves[slave1].is_accessible assert m_sess.slaves[slave2].is_accessible slave2.close() assert not m_sess.slaves[slave2].is_accessible m_sess.slaves.open(slave2) assert slave2.is_accessible
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_project(): pr = ss.Project('test_master') assert pr.last_ip == 'localhost'