def test_get_session_file_path(name, pid, expected): import kano_profile.tracker.tracking_sessions as tracking_sessions session_file_path = os.path.abspath( tracking_sessions.get_session_file_path(name, pid) ) assert session_file_path == expected
def test_get_open_sessions(tracking_session, sample_tracking_sessions): import kano_profile.tracker.tracking_sessions as tracking_sessions sample_sessions = sample_tracking_sessions[:] open_session = tracking_session.format_session('active-session', 987654321, os.getpid(), 55, True) sample_sessions.append(open_session) tracking_session.setup_sessions(sample_sessions) tracking_session.setup_paused_sessions(None) listed_sessions = tracking_sessions.get_open_sessions() for session in listed_sessions: assert session.is_open() assert len(listed_sessions) == 1 listed_session = listed_sessions[0] open_session_path = tracking_sessions.get_session_file_path( open_session['name'], open_session['pid']) assert os.path.basename(open_session_path) == listed_session.file assert os.path.abspath(open_session_path) == listed_session.path assert open_session['name'] == listed_session.name assert open_session['pid'] == listed_session.pid
def test_get_session_file_path(name, pid, expected): import kano_profile.tracker.tracking_sessions as tracking_sessions session_file_path = os.path.abspath( tracking_sessions.get_session_file_path(name, pid) ) assert session_file_path == expected
def test_get_open_sessions(tracking_session, sample_tracking_sessions): import kano_profile.tracker.tracking_sessions as tracking_sessions sample_sessions = sample_tracking_sessions[:] open_session = tracking_session.format_session( 'active-session', 987654321, os.getpid(), 55, True ) sample_sessions.append(open_session) tracking_session.setup_sessions(sample_sessions) tracking_session.setup_paused_sessions(None) listed_sessions = tracking_sessions.get_open_sessions() for session in listed_sessions: assert session.is_open() assert len(listed_sessions) == 1 listed_session = listed_sessions[0] open_session_path = tracking_sessions.get_session_file_path( open_session['name'], open_session['pid'] ) assert os.path.basename(open_session_path) == listed_session.file assert os.path.abspath(open_session_path) == listed_session.path assert open_session['name'] == listed_session.name assert open_session['pid'] == listed_session.pid
def test_list_sessions(tracking_session, sample_tracking_sessions): import kano_profile.tracker.tracking_sessions as tracking_sessions tracking_session.setup_sessions(sample_tracking_sessions) tracking_session.setup_paused_sessions(None) listed_sessions = tracking_sessions.list_sessions() assert len(listed_sessions) == len(sample_tracking_sessions) for session in sample_tracking_sessions: session_path = tracking_sessions.get_session_file_path( session['name'], session['pid']) assert os.path.basename(session_path) in listed_sessions
def track_subprocess(name, cmd): """ Launch and track the session of a process. :param name: Name of the session. :type name: str :param cmd: The command line (env vars are not supported). :type cmd: str """ cmd_args = shlex.split(cmd) p = subprocess.Popen(cmd_args) pid = p.pid session_start(name, pid) p.wait() session_end(get_session_file_path(name, pid))
def test_list_sessions(tracking_session, sample_tracking_sessions): import kano_profile.tracker.tracking_sessions as tracking_sessions tracking_session.setup_sessions(sample_tracking_sessions) tracking_session.setup_paused_sessions(None) listed_sessions = tracking_sessions.list_sessions() assert len(listed_sessions) == len(sample_tracking_sessions) for session in sample_tracking_sessions: session_path = tracking_sessions.get_session_file_path( session['name'], session['pid'] ) assert os.path.basename(session_path) in listed_sessions
def track_subprocess(name, cmd): """ Launch and track the session of a process. :param name: Name of the session. :type name: str :param cmd: The command line (env vars are not supported). :type cmd: str """ cmd_args = shlex.split(cmd) p = subprocess.Popen(cmd_args) pid = p.pid session_start(name, pid) p.wait() session_end(get_session_file_path(name, pid))