"""Scenario 1 for unit-testing of stop-idle-sessions

In Scenario 1, there is a single active user with one SSH session and one
non-idle VNC session. The SSH session is actively tunneled into the VNC
session. Separately, the root user is SSH'd into the system (for observation)
and there is an idle GDM session running.
"""
# Don't worry about how many lines are in this file. It's basically just a
# dataset (albeit with actual Python objects).
# pylint: disable=too-many-lines


import datetime
from ipaddress import ip_address, IPv4Address, IPv6Address
from textwrap import dedent
from typing import Any, List, Mapping, Optional, Set, Tuple, Union
from unittest.mock import MagicMock, Mock

import stop_idle_sessions.logind
import stop_idle_sessions.main
import stop_idle_sessions.ps
import stop_idle_sessions.ss
import stop_idle_sessions.tty

from . import test_logind, test_main, test_ps, test_ss


class Scenario1LogindTestCase(test_logind.LogindTestCase):
    """Scenario1 unit testing for the logind module

    See the docstring for the test_scenario1 module for an overall description
    of Scenario 1 (single active user w/ VNC).

    This was generated by the following shell pipeline:
        loginctl | tail -n +2 | head -n -2 | awk '{print $1}' |
        xargs -L1 loginctl show-session
    """

    def _mock_gio_results_spec(self) -> Mapping[str, Mapping[str, str]]:
        """Input data to populate the mock Gio object (logind API)"""
        return {
            "1267": {
                "Id": "1267",
                "User": "1002",
                "TTY": "pts/2",
                "Scope": "session-1267.scope",
                "Leader": "952165"
            },
            "1301": {
                "Id": "1301",
                "User": "0",
                "TTY": "pts/1",
                "Scope": "session-1301.scope",
                "Leader": "994974"
            },
            "1337": {
                "Id": "1337",
                "User": "1002",
                "TTY": "pts/0",
                "Scope": "session-1337.scope",
                "Leader": "1050298"
            },
            "c1": {
                "Id": "c1",
                "User": "42",
                "TTY": "tty1",
                "Scope": "session-c1.scope",
                "Leader": "5655"
            }
        }

    def _expected_logind_sessions(self) -> List[Mapping[str, Any]]:
        """Expected set of logind session attributes to be returned"""
        return [
            {
                "session_id": "1267",
                "uid": 1002,
                "tty": "pts/2",
                "leader": 952165,
                "scope": "session-1267.scope",
                "scope_path": "/user.slice/user-1002.slice/session-1267.scope"
            },
            {
                "session_id": "1301",
                "uid": 0,
                "tty": "pts/1",
                "leader": 994974,
                "scope": "session-1301.scope",
                "scope_path": "/user.slice/user-0.slice/session-1301.scope"
            },
            {
                "session_id": "1337",
                "uid": 1002,
                "tty": "pts/0",
                "leader": 1050298,
                "scope": "session-1337.scope",
                "scope_path": "/user.slice/user-1002.slice/session-1337.scope"
            },
            {
                "session_id": "c1",
                "uid": 42,
                "tty": "tty1",
                "leader": 5655,
                "scope": "session-c1.scope",
                "scope_path": "/user.slice/user-42.slice/session-c1.scope"
            }
        ]


class Scenario1CgroupPidsTestCase(test_ps.CgroupPidsTestCase):
    """Scenario1 unit testing for the ps module

    See the docstring for the test_scenario1 module for an overall description
    of Scenario 1 (single active user w/ VNC).

    This was generated by the following shell pipeline:
        cat /sys/fs/cgroup/systemd/user.slice/user-1002.slice/session-1267.scope/cgroup.procs |
        xargs -L1 ps -o 'pid,args' --no-headers -p

    In Scenario 1, we deliberately choose the Xvnc session which has a TON of
    child processes, just to make sure that no parsing errors occur with these
    unusual commandlines.
    """

    def _mock_process_specs(self) -> Mapping[int, str]:
        """Input data to populate the filesystem mock for the cgroup sysfs"""
        # Yes, there are some very long lines here!
        # pylint: disable=line-too-long
        return {
            772211: "/usr/libexec/gvfsd-metadata",
            952570: "/usr/bin/Xvnc :1 -auth /u/wk/auser/.Xauthority -desktop computer:1 (auser) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /u/wk/auser/.vnc/passwd -rfbport 5901 -localhost",
            952581: "/bin/sh /u/wk/auser/.vnc/xstartup",
            952582: "/usr/libexec/gnome-session-binary",
            952591: "dbus-launch --sh-syntax --exit-with-session",
            952592: "/usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session",
            952644: "/usr/libexec/at-spi-bus-launcher",
            952649: "/usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3",
            952652: "/usr/libexec/at-spi2-registryd --use-gnome-session",
            952656: "/usr/libexec/gvfsd",
            952663: "/usr/libexec/gvfsd-fuse /run/user/1002/gvfs -f -o big_writes",
            952715: "/usr/bin/gnome-keyring-daemon --start --components=pkcs11",
            952727: "/usr/bin/gnome-shell",
            952766: "ibus-daemon --xim --panel disable",
            952768: "/usr/libexec/xdg-permission-store",
            952770: "/usr/libexec/gnome-shell-calendar-server",
            952774: "/usr/libexec/ibus-dconf",
            952775: "/usr/libexec/ibus-extension-gtk3",
            952777: "/usr/libexec/ibus-x11 --kill-daemon",
            952779: "/usr/libexec/ibus-portal",
            952805: "/usr/libexec/evolution-source-registry",
            952817: "/usr/libexec/goa-daemon",
            952819: "/usr/libexec/dconf-service",
            952837: "/usr/libexec/goa-identity-service",
            952841: "/usr/libexec/gvfs-udisks2-volume-monitor",
            952853: "/usr/libexec/gvfs-mtp-volume-monitor",
            952861: "/usr/libexec/gvfs-goa-volume-monitor",
            952868: "/usr/libexec/gvfs-gphoto2-volume-monitor",
            952875: "/usr/libexec/gvfs-afc-volume-monitor",
            952885: "/usr/libexec/gsd-power",
            952888: "/usr/libexec/gsd-print-notifications",
            952889: "/usr/libexec/gsd-rfkill",
            952890: "/usr/libexec/gsd-screensaver-proxy",
            952891: "/usr/libexec/gsd-sharing",
            952892: "/usr/libexec/gsd-smartcard",
            952893: "/usr/libexec/gsd-sound",
            952894: "/usr/libexec/gsd-xsettings",
            952895: "/usr/libexec/gsd-subman",
            952898: "/usr/libexec/gsd-wacom",
            952904: "/usr/libexec/gsd-account",
            952905: "/usr/libexec/gsd-clipboard",
            952907: "/usr/libexec/gsd-a11y-settings",
            952909: "/usr/libexec/gsd-datetime",
            952910: "/usr/libexec/evolution-calendar-factory",
            952911: "/usr/libexec/gsd-color",
            952913: "/usr/libexec/gsd-keyboard",
            952919: "/usr/libexec/gsd-housekeeping",
            952921: "/usr/libexec/gsd-mouse",
            952935: "/usr/libexec/gsd-media-keys",
            952941: "/usr/libexec/ibus-engine-simple",
            952959: "/usr/libexec/gsd-printer",
            953009: "/usr/libexec/evolution-calendar-factory-subprocess --factory all --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx952910x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calendar/952910/2",
            953028: "/usr/libexec/evolution-addressbook-factory",
            953050: "/usr/libexec/evolution-addressbook-factory-subprocess --factory all --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.AddressBookx953028x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/AddressBook/953028/2",
            953201: "/usr/libexec/gsd-disk-utility-notify",
            953207: "/usr/bin/gnome-software --gapplication-service",
            953209: "/usr/libexec/evolution/evolution-alarm-notify",
            953210: "/usr/libexec/tracker-miner-fs",
            953212: "/usr/libexec/tracker-miner-apps",
            953217: "/usr/libexec/tracker-store"
        }

    def _expected_process_objects(self) -> List[stop_idle_sessions.ps.Process]:
        """Expected set of processes to be parsed out of the cgroup sysfs"""
        # Yes, there are some very long lines here!
        # pylint: disable=line-too-long
        return [
            stop_idle_sessions.ps.Process(
                    pid=772211,
                    cmdline="/usr/libexec/gvfsd-metadata",
                    environ={}
            ),
            stop_idle_sessions.ps.Process(
                    pid=952570,
                    cmdline="/usr/bin/Xvnc :1 -auth /u/wk/auser/.Xauthority -desktop computer:1 (auser) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /u/wk/auser/.vnc/passwd -rfbport 5901 -localhost",
                    environ={}
            ),
            stop_idle_sessions.ps.Process(
                    pid=952581,
                    cmdline="/bin/sh /u/wk/auser/.vnc/xstartup",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952582,
                    cmdline="/usr/libexec/gnome-session-binary",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952591,
                    cmdline="dbus-launch --sh-syntax --exit-with-session",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952592,
                    cmdline="/usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952644,
                    cmdline="/usr/libexec/at-spi-bus-launcher",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952649,
                    cmdline="/usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952652,
                    cmdline="/usr/libexec/at-spi2-registryd --use-gnome-session",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952656,
                    cmdline="/usr/libexec/gvfsd",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952663,
                    cmdline="/usr/libexec/gvfsd-fuse /run/user/1002/gvfs -f -o big_writes",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952715,
                    cmdline="/usr/bin/gnome-keyring-daemon --start --components=pkcs11",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952727,
                    cmdline="/usr/bin/gnome-shell",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952766,
                    cmdline="ibus-daemon --xim --panel disable",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952768,
                    cmdline="/usr/libexec/xdg-permission-store",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952770,
                    cmdline="/usr/libexec/gnome-shell-calendar-server",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952774,
                    cmdline="/usr/libexec/ibus-dconf",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952775,
                    cmdline="/usr/libexec/ibus-extension-gtk3",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952777,
                    cmdline="/usr/libexec/ibus-x11 --kill-daemon",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952779,
                    cmdline="/usr/libexec/ibus-portal",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952805,
                    cmdline="/usr/libexec/evolution-source-registry",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952817,
                    cmdline="/usr/libexec/goa-daemon",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952819,
                    cmdline="/usr/libexec/dconf-service",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952837,
                    cmdline="/usr/libexec/goa-identity-service",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952841,
                    cmdline="/usr/libexec/gvfs-udisks2-volume-monitor",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952853,
                    cmdline="/usr/libexec/gvfs-mtp-volume-monitor",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952861,
                    cmdline="/usr/libexec/gvfs-goa-volume-monitor",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952868,
                    cmdline="/usr/libexec/gvfs-gphoto2-volume-monitor",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952875,
                    cmdline="/usr/libexec/gvfs-afc-volume-monitor",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952885,
                    cmdline="/usr/libexec/gsd-power",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952888,
                    cmdline="/usr/libexec/gsd-print-notifications",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952889,
                    cmdline="/usr/libexec/gsd-rfkill",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952890,
                    cmdline="/usr/libexec/gsd-screensaver-proxy",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952891,
                    cmdline="/usr/libexec/gsd-sharing",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952892,
                    cmdline="/usr/libexec/gsd-smartcard",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952893,
                    cmdline="/usr/libexec/gsd-sound",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952894,
                    cmdline="/usr/libexec/gsd-xsettings",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952895,
                    cmdline="/usr/libexec/gsd-subman",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952898,
                    cmdline="/usr/libexec/gsd-wacom",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952904,
                    cmdline="/usr/libexec/gsd-account",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952905,
                    cmdline="/usr/libexec/gsd-clipboard",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952907,
                    cmdline="/usr/libexec/gsd-a11y-settings",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952909,
                    cmdline="/usr/libexec/gsd-datetime",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952910,
                    cmdline="/usr/libexec/evolution-calendar-factory",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952911,
                    cmdline="/usr/libexec/gsd-color",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952913,
                    cmdline="/usr/libexec/gsd-keyboard",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952919,
                    cmdline="/usr/libexec/gsd-housekeeping",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952921,
                    cmdline="/usr/libexec/gsd-mouse",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952935,
                    cmdline="/usr/libexec/gsd-media-keys",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952941,
                    cmdline="/usr/libexec/ibus-engine-simple",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=952959,
                    cmdline="/usr/libexec/gsd-printer",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953009,
                    cmdline="/usr/libexec/evolution-calendar-factory-subprocess --factory all --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx952910x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calendar/952910/2",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953028,
                    cmdline="/usr/libexec/evolution-addressbook-factory",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953050,
                    cmdline="/usr/libexec/evolution-addressbook-factory-subprocess --factory all --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.AddressBookx953028x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/AddressBook/953028/2",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953201,
                    cmdline="/usr/libexec/gsd-disk-utility-notify",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953207,
                    cmdline="/usr/bin/gnome-software --gapplication-service",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953209,
                    cmdline="/usr/libexec/evolution/evolution-alarm-notify",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953210,
                    cmdline="/usr/libexec/tracker-miner-fs",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953212,
                    cmdline="/usr/libexec/tracker-miner-apps",
                    environ={
                        'DISPLAY': ':1'
                    }
            ),
            stop_idle_sessions.ps.Process(
                    pid=953217,
                    cmdline="/usr/libexec/tracker-store",
                    environ={
                        'DISPLAY': ':1'
                    }
            )
        ]


class Scenario1LoopbackConnectionTestCase(test_ss.LoopbackConnectionTestCase):
    """Scenario1 unit testing for the ss module

    See the docstring for the test_scenario1 module for an overall description
    of Scenario 1 (single active user w/ VNC).

    This was generated by the following shell pipeline:
        /usr/sbin/ss --all --no-header --numeric --oneline --processes --tcp
    """

    def _mock_raw_ss_output(self) -> str:
        """Input data to populate the mocked network connections table"""
        return dedent("""\
            LISTEN    0      100         127.0.0.1:25           0.0.0.0:*     users:(("master",pid=5337,fd=14))                          
            LISTEN    0      5           127.0.0.1:5901         0.0.0.0:*     users:(("Xvnc",pid=952570,fd=6))                           
            LISTEN    0      128           0.0.0.0:111          0.0.0.0:*     users:(("rpcbind",pid=4410,fd=4),("systemd",pid=1,fd=42))  
            LISTEN    0      128           0.0.0.0:22           0.0.0.0:*     users:(("sshd",pid=4960,fd=3))                             
            LISTEN    0      2048        127.0.0.1:631          0.0.0.0:*     users:(("cupsd",pid=162159,fd=8))                          
            ESTAB     0      452        10.0.0.169:22        10.0.3.209:57343 users:(("sshd",pid=1256518,fd=4),("sshd",pid=1256491,fd=4))
            SYN-SENT  0      1          10.0.0.169:45198 151.101.193.91:443   users:(("gnome-software",pid=1259638,fd=22))               
            TIME-WAIT 0      0          10.0.0.169:41180     10.0.4.244:636                                                              
            TIME-WAIT 0      0          10.0.0.169:53546     10.0.2.100:3128                                                             
            ESTAB     0      0           127.0.0.1:5901       127.0.0.1:49688 users:(("Xvnc",pid=952570,fd=23))                          
            SYN-SENT  0      1          10.0.0.169:40676 151.101.129.91:443   users:(("gnome-shell",pid=1259171,fd=34))                  
            ESTAB     0      0          10.0.0.169:22         10.0.1.53:41516 users:(("sshd",pid=1259753,fd=4),("sshd",pid=1259733,fd=4))
            ESTAB     0      0           127.0.0.1:49688      127.0.0.1:5901  users:(("sshd",pid=1256518,fd=7))                          
            ESTAB     0      0          10.0.0.169:22         10.0.1.53:39700 users:(("sshd",pid=1050325,fd=4),("sshd",pid=1050298,fd=4))
            TIME-WAIT 0      0          10.0.0.169:41178     10.0.4.244:636                                                              
            ESTAB     0      0          10.0.0.169:725       10.0.1.202:2049                                                             
            TIME-WAIT 0      0          10.0.0.169:53532     10.0.2.100:3128                                                             
            ESTAB     0      0          10.0.0.169:22         10.0.1.53:54592 users:(("sshd",pid=995013,fd=4),("sshd",pid=994974,fd=4))  
            TIME-WAIT 0      0          10.0.0.169:41196     10.0.4.244:636                                                              
            TIME-WAIT 0      0          10.0.0.169:41176     10.0.4.244:636                                                              
            SYN-SENT  0      1          10.0.0.169:49948 151.101.193.91:443   users:(("gnome-shell",pid=6978,fd=32))                     
            ESTAB     0      612        10.0.0.169:22        10.0.3.209:57353 users:(("sshd",pid=1258236,fd=4),("sshd",pid=1258006,fd=4))
            TIME-WAIT 0      0          10.0.0.169:53550     10.0.2.100:3128                                                             
            ESTAB     0      0          10.0.0.169:861       10.0.1.203:2049                                                             
            LISTEN    0      100             [::1]:25              [::]:*     users:(("master",pid=5337,fd=15))                          
            LISTEN    0      5               [::1]:5901            [::]:*     users:(("Xvnc",pid=952570,fd=7))                           
            LISTEN    0      128              [::]:111             [::]:*     users:(("rpcbind",pid=4410,fd=6),("systemd",pid=1,fd=44))  
            LISTEN    0      2048            [::1]:631             [::]:*     users:(("cupsd",pid=162159,fd=7))                          
        """)

    def _expected_listening_ports(self) -> Set[int]:
        """Expected set of listening ports parsed out of the mock ss data"""
        return set([22, 25, 111, 631, 5901])

    def _expected_peer_pairs(self) -> Set[Tuple[Union[IPv4Address,
                                                      IPv6Address], int]]:
        """Expected set of remote peers parsed from the established conns"""
        return set([
                (ip_address('10.0.1.53'), 39700),
                (ip_address('10.0.1.53'), 41516),
                (ip_address('10.0.1.53'), 54592),
                (ip_address('10.0.1.202'), 2049),
                (ip_address('10.0.1.203'), 2049),
                (ip_address('10.0.3.209'), 57343),
                (ip_address('10.0.3.209'), 57353),
                (ip_address('127.0.0.1'), 5901),
                (ip_address('127.0.0.1'), 49688)
        ])

    def _expected_connections(self) -> List[stop_idle_sessions.ss.LoopbackConnection]:
        """Expected set of loopback connections identified from these conns"""
        return [
            stop_idle_sessions.ss.LoopbackConnection(
                    client=stop_idle_sessions.ss.Socket(
                        addr=ip_address('127.0.0.1'),
                        port=49688,
                        processes=[stop_idle_sessions.ps.Process(
                            pid=1256518,
                            cmdline="",
                            environ={}
                        )]
                    ),
                    server=stop_idle_sessions.ss.Socket(
                        addr=ip_address('127.0.0.1'),
                        port=5901,
                        processes=[stop_idle_sessions.ps.Process(
                            pid=952570,
                            cmdline="",
                            environ={}
                        )]
                    )
            )
        ]


class Scenario1MainLoopTestCase(test_main.MainLoopTestCase):
    """Scenario1 unit testing for the main module

    See the docstring for the test_scenario1 module for an overall description
    of Scenario 1 (single active user w/ VNC).

    See also the other Scenario1* TestCases for hints about how to generate
    the input data which was used to specify this test fixture.
    """

    def _mock_get_all_sessions(self) -> List[stop_idle_sessions.logind.Session]:
        """Input data to mock out the logind module and D-Bus"""
        return [
            Mock(spec_set=stop_idle_sessions.logind.Session,
                 session_id="1267",
                 session_type="tty",
                 uid=1002,
                 tty="pts/2",
                 leader=952165,
                 scope="session-1267.scope",
                 scope_path="/user.slice/user-1002.slice/session-1267.scope"),
            Mock(spec_set=stop_idle_sessions.logind.Session,
                 session_id="1301",
                 session_type="tty",
                 uid=0,
                 tty="pts/1",
                 leader=994974,
                 scope="session-1301.scope",
                 scope_path="/user.slice/user-0.slice/session-1301.scope"),
            Mock(spec_set=stop_idle_sessions.logind.Session,
                 session_id="1337",
                 session_type="tty",
                 uid=1002,
                 tty="pts/0",
                 leader=1050298,
                 scope="session-1337.scope",
                 scope_path="/user.slice/user-1002.slice/session-1337.scope"),
            Mock(spec_set=stop_idle_sessions.logind.Session,
                 session_id="c1",
                 session_type="wayland",
                 uid=42,
                 tty="tty1",
                 leader=5655,
                 scope="session-c1.scope",
                 scope_path="/user.slice/user-42.slice/session-c1.scope")
        ]

    def _mock_find_loopback_connections(self) -> List[stop_idle_sessions.ss.LoopbackConnection]:
        """Input data to mock out the ss utility and module"""
        return [
            stop_idle_sessions.ss.LoopbackConnection(
                client=stop_idle_sessions.ss.Socket(
                    addr=ip_address('127.0.0.1'),
                    port=49688,
                    processes=[stop_idle_sessions.ps.Process(
                        pid=1256518,
                        cmdline="",
                        environ={})
                    ]
                ),
                server=stop_idle_sessions.ss.Socket(
                    addr=ip_address('127.0.0.1'),
                    port=5901,
                    processes=[stop_idle_sessions.ps.Process(
                        pid=952570,
                        cmdline="",
                        environ={})
                    ]
                )
            )
        ]

    def _mock_processes_in_scope_path(self,
                                      scope_path: str) -> List[stop_idle_sessions.ps.Process]:
        """Input data to mock out the ps and cgroup interface module"""

        if scope_path == "/user.slice/user-1002.slice/session-1267.scope":
            pids = list(map(lambda pid: stop_idle_sessions.ps.Process(pid=pid,
                                                                      cmdline="",
                                                                      environ={}),
                            [772211, 952582, 952591, 952592, 952644, 952649,
                             952652, 952656, 952663, 952715, 952727, 952766,
                             952768, 952770, 952774, 952775, 952777, 952779,
                             952805, 952817, 952819, 952837, 952841, 952853,
                             952861, 952868, 952875, 952885, 952888, 952889,
                             952890, 952891, 952892, 952893, 952894, 952895,
                             952898, 952904, 952905, 952907, 952909, 952910,
                             952911, 952913, 952919, 952921, 952935, 952941,
                             952959, 953009, 953028, 953050, 953201, 953207,
                             953209, 953210, 953212, 953217]))

            pids.append(stop_idle_sessions.ps.Process(
                    pid=952570,
                    cmdline=("/usr/bin/Xvnc :1 -auth /u/wk/auser/.Xauthority "
                             "-desktop computer:1 (auser) -fp "
                             "catalogue:/etc/X11/fontpath.d -geometry "
                             "1024x768 -pn -rfbauth /u/wk/auser/.vnc/passwd "
                             "-rfbport 5901 -localhost"),
                    environ={}
            ))
            pids.append(stop_idle_sessions.ps.Process(
                    pid=952581,
                    cmdline="/bin/sh /u/wk/auser/.vnc/xstartup",
                    environ={'DISPLAY': ":1"}
            ))

            return pids

        if scope_path == "/user.slice/user-0.slice/session-1301.scope":
            return list(map(lambda pid: stop_idle_sessions.ps.Process(pid=pid,
                                                                      cmdline="",
                                                                      environ={}),
                            [1258996, 1259009, 1259010, 1259026, 1259028,
                             1259067, 1259083, 1259088, 1259093, 1259097,
                             1259105, 1259157, 1259171, 1259210, 1259212,
                             1259214, 1259218, 1259219, 1259221, 1259223,
                             1259235, 1259257, 1259268, 1259271, 1259280,
                             1259285, 1259290, 1259297, 1259305, 1259307,
                             1259308, 1259309, 1259310, 1259311, 1259312,
                             1259313, 1259314, 1259315, 1259321, 1259322,
                             1259325, 1259328, 1259329, 1259331, 1259337,
                             1259342, 1259343, 1259347, 1259349, 1259350,
                             1259366, 1259438, 1259452, 1259454, 1259473,
                             1259632, 1259638, 1259640]))

        if scope_path == "/user.slice/user-1002.slice/session-1337.scope":
            return list(map(lambda pid: stop_idle_sessions.ps.Process(pid=pid,
                                                                      cmdline="",
                                                                      environ={}),
                            [1050298, 1256518, 1256520]))

        if scope_path == "/user.slice/user-42.slice/session-c1.scope":
            return list(map(lambda pid: stop_idle_sessions.ps.Process(pid=pid,
                                                                      cmdline="",
                                                                      environ={}),
                            [5655, 5875, 5877, 6221, 6243, 6263, 6544, 6604,
                             6620, 6978, 9150, 9273, 9279, 9283, 9670, 10363,
                             10375, 10377, 10383, 10396, 10418, 10422, 10426,
                             10443, 10448, 10474, 10483, 10484, 10492, 10493,
                             10494, 10495, 10518]))

        raise KeyError(f'Unexpected scope argument: {scope_path}')

    def _mock_uid_to_username(self, uid: int) -> str:
        """Convert numeric UIDs to symbolic usernames"""
        return {0: 'root', 42: 'gdm', 1002: 'auser'}[uid]

    def _mock_retrieve_idle_time(self,
                                 display: str,
                                 xauthority: Optional[str]) -> Optional[datetime.timedelta]:
        """Mock information about an X11 DISPLAY's idle timeout"""
        assert xauthority is None or isinstance(xauthority, str)

        if display == ':0':
            return datetime.timedelta(seconds=47 * 60)
        if display == ':1':
            return datetime.timedelta(seconds=35)

        raise KeyError(f'Unexpected DISPLAY argument: {display}')

    def _mock_tty(self, name: str) -> stop_idle_sessions.tty.TTY:
        """Mock information about a tty/pty's timestamps"""

        if name == 'pts/2':
            atty = Mock(spec=stop_idle_sessions.tty.TTY,
                        full_name='/dev/pts/2',
                        atime=datetime.datetime(2024, 11, 22,
                                                6, 15, 0, 0,
                                                tzinfo=datetime.timezone.utc),
                        mtime=datetime.datetime(2024, 11, 22,
                                                6, 16, 0, 0,
                                                tzinfo=datetime.timezone.utc))
            atty.configure_mock(name=name)
            return atty

        if name == 'pts/1':
            atty = Mock(spec=stop_idle_sessions.tty.TTY,
                        name=name,
                        full_name='/dev/pts/1',
                        atime=datetime.datetime(2024, 11, 22,
                                                5, 46, 0, 0,
                                                tzinfo=datetime.timezone.utc),
                        mtime=datetime.datetime(2024, 11, 22,
                                                5, 46, 0, 0,
                                                tzinfo=datetime.timezone.utc))
            atty.configure_mock(name=name)
            return atty

        if name == 'pts/0':
            atty = Mock(spec=stop_idle_sessions.tty.TTY,
                        name=name,
                        full_name='/dev/pts/0',
                        atime=datetime.datetime(2024, 11, 22,
                                                6, 15, 0, 0,
                                                tzinfo=datetime.timezone.utc),
                        mtime=datetime.datetime(2024, 11, 22,
                                                6, 14, 0, 0,
                                                tzinfo=datetime.timezone.utc))
            atty.configure_mock(name=name)
            return atty

        if name == 'tty1':
            atty = Mock(spec=stop_idle_sessions.tty.TTY,
                        name=name,
                        full_name='/dev/tty1',
                        atime=datetime.datetime(2024, 11, 22,
                                                5, 30, 0, 0,
                                                tzinfo=datetime.timezone.utc),
                        mtime=datetime.datetime(2024, 11, 22,
                                                5, 30, 0, 0,
                                                tzinfo=datetime.timezone.utc))
            atty.configure_mock(name=name)
            return atty

        raise KeyError(f'Unexpected tty/pty name: {name}')

    def _now(self) -> datetime.datetime:
        """Return a fixed point in time to compare timedeltas against"""
        return datetime.datetime(2024, 11, 22,
                                 6, 17, 0, 0,
                                 tzinfo=datetime.timezone.utc)

    def _excluded_users(self) -> List[str]:
        """Supplement session assertion testing with a set of excluded users"""
        return []

    def _expected_sessions(self) -> List[stop_idle_sessions.main.Session]:
        """Register the expected set of fully-fleshed-out session objects"""

        logind_sessions = self._mock_get_all_sessions()

        session_1267 = stop_idle_sessions.main.Session(
                session=logind_sessions[0],
                tty=self._mock_tty('pts/2'),
                display=':1',
                display_idle=datetime.timedelta(seconds=35),
                username='auser',
                processes=[stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=772211,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952570,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952581,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952582,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952591,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952592,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952644,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952649,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952652,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952656,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952663,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952715,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952727,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952766,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952768,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952770,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952774,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952775,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952777,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952779,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952805,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952817,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952819,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952837,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952841,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952853,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952861,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952868,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952875,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952885,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952888,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952889,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952890,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952891,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952892,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952893,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952894,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952895,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952898,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952904,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952905,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952907,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952909,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952910,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952911,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952913,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952919,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952921,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952935,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952941,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=952959,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953009,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953028,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953050,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953201,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953207,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953209,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953210,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953212,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=953217,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[])]
        )

        session_1301 = stop_idle_sessions.main.Session(
                session=logind_sessions[1],
                tty=self._mock_tty('pts/1'),
                display=None,
                display_idle=None,
                username='root',
                processes=[stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1258996,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259009,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259010,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259026,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259028,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259067,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259083,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259088,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259093,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259097,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259105,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259157,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259171,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259210,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259212,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259214,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259218,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259219,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259221,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259223,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259235,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259257,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259268,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259271,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259280,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259285,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259290,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259297,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259305,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259307,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259308,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259309,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259310,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259311,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259312,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259313,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259314,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259315,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259321,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259322,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259325,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259328,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259329,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259331,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259337,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259342,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259343,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259347,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259349,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259350,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259366,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259438,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259452,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259454,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259473,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259632,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259638,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1259640,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[])]
        )

        session_1337 = stop_idle_sessions.main.Session(
                session=logind_sessions[2],
                tty=self._mock_tty('pts/0'),
                display=None,
                display_idle=None,
                username='auser',
                processes=[stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1050298,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1256518,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[
                                    stop_idle_sessions.ps.Process(pid=952570,
                                                                  cmdline="",
                                                                  environ={})
                                ],
                                tunneled_sessions=[session_1267]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=1256520,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[])]
        )

        session_c1 = stop_idle_sessions.main.Session(
                session=logind_sessions[3],
                tty=self._mock_tty('tty1'),
                display=':0',
                display_idle=datetime.timedelta(seconds=47 * 60),
                username='gdm',
                processes=[stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=5655,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=5875,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=5877,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=6221,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=6243,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=6263,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=6544,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=6604,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=6620,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=6978,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=9150,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=9273,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=9279,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=9283,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=9670,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10363,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10375,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10377,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10383,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10396,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10418,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10422,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10426,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10443,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10448,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10474,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10483,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10484,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10492,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10493,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10494,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10495,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[]),
                           stop_idle_sessions.main.SessionProcess(
                                process=stop_idle_sessions.ps.Process(pid=10518,
                                                                      cmdline="",
                                                                      environ={}),
                                tunneled_processes=[],
                                tunneled_sessions=[])]
        )

        return [session_1267, session_1301, session_1337, session_c1]

    def _expected_results(self) -> List[Tuple[bool, bool,
                                              Optional[datetime.timedelta]]]:
        """Specify the expected handling for each of the _expected_sessions

        The returned tuple for _expected_results is as follows:
          (skipped_exempt: bool, terminated: bool, idle_metric: timedelta)
        """

        return [
                # session ID = 1267
                # 35-seconde idle determined by DISPLAY=:1
                (False, False, datetime.timedelta(seconds=35)),

                # session ID = 1301
                # 31-minute idle (terminated) based on pty atime/mtime
                (False, True, datetime.timedelta(seconds=31 * 60)),

                # session ID = 1337
                # 1-minute idle determined by session 1267
                (False, False, datetime.timedelta(seconds=35)),

                # session ID = c1
                # 47-minute idle (NOT terminated) based on DISPLAY=:0
                (True, False, datetime.timedelta(seconds=47 * 60))
        ]
