Esempio n. 1
0
    def test_service_keep_alive_missing(self):
        '''
        test _always_running_service when keep_alive not in dict
        '''
        srv_name = 'com.apple.atrun'
        info = {
            'plist': {
                'EnableTransactions': True,
                'ProgramArguments': ['/usr/libexec/ntpd-wrapper'],
                'Label': 'org.ntp.ntpd'
            }
        }

        with patch.object(mac_service, 'show', MagicMock(return_value=info)):
            assert mac_service._always_running_service(srv_name) is False
Esempio n. 2
0
def test_service_keep_alive_missing():
    """
    test _always_running_service when keep_alive not in dict
    """
    srv_name = "com.apple.atrun"
    info = {
        "plist": {
            "EnableTransactions": True,
            "ProgramArguments": ["/usr/libexec/ntpd-wrapper"],
            "Label": "org.ntp.ntpd",
        }
    }

    with patch.object(mac_service, "show", MagicMock(return_value=info)):
        assert mac_service._always_running_service(srv_name) is False
Esempio n. 3
0
def test_service_keep_alive_empty():
    """
    test _always_running_service when keep_alive
    is empty
    """
    srv_name = "com.apple.atrun"
    info = {
        "plist": {
            "EnableTransactions": True,
            "ProgramArguments": ["/usr/libexec/ntpd-wrapper"],
            "Label": "org.ntp.ntpd",
            "KeepAlive": {},
        }
    }

    with patch.object(mac_service, "show", MagicMock(return_value=info)):
        with patch("os.path.exists", MagicMock(return_value=False)):
            assert mac_service._always_running_service(srv_name) is False
Esempio n. 4
0
    def test_service_keep_alive_empty(self):
        '''
        test _always_running_service when keep_alive
        is empty
        '''
        srv_name = 'com.apple.atrun'
        info = {
            'plist': {
                'EnableTransactions': True,
                'ProgramArguments': ['/usr/libexec/ntpd-wrapper'],
                'Label': 'org.ntp.ntpd',
                'KeepAlive': {}
            }
        }

        with patch.object(mac_service, 'show', MagicMock(return_value=info)):
            with patch('os.path.exists', MagicMock(return_value=False)):
                assert mac_service._always_running_service(srv_name) is False
Esempio n. 5
0
def test_service_keep_alive_wrong_setting():
    """
    test _always_running_service when keep_alive
    has pathstate set in plist file
    """
    srv_name = "com.apple.atrun"
    info = {
        "plist": {
            "EnableTransactions": True,
            "ProgramArguments": ["/usr/libexec/ntpd-wrapper"],
            "Label": "org.ntp.ntpd",
            "KeepAlive": {
                "Doesnotexist": {
                    "doesnt_exist": True
                }
            },
        }
    }

    with patch.object(mac_service, "show", MagicMock(return_value=info)):
        assert mac_service._always_running_service(srv_name) is False
Esempio n. 6
0
    def test_service_keep_alive_wrong_setting(self):
        '''
        test _always_running_service when keep_alive
        has pathstate set in plist file
        '''
        srv_name = 'com.apple.atrun'
        info = {
            'plist': {
                'EnableTransactions': True,
                'ProgramArguments': ['/usr/libexec/ntpd-wrapper'],
                'Label': 'org.ntp.ntpd',
                'KeepAlive': {
                    'Doesnotexist': {
                        'doesnt_exist': True
                    }
                }
            }
        }

        with patch.object(mac_service, 'show', MagicMock(return_value=info)):
            assert mac_service._always_running_service(srv_name) is False
Esempio n. 7
0
def test_service_keep_alive_pathstate():
    """
    test _always_running_service when keep_alive
    has pathstate set in plist file
    """
    srv_name = "com.apple.atrun"
    info = {
        "plist": {
            "EnableTransactions": True,
            "ProgramArguments": ["/usr/libexec/ntpd-wrapper"],
            "Label": "org.ntp.ntpd",
            "KeepAlive": {
                "PathState": {
                    "/private/etc/ntp.conf": True
                }
            },
        }
    }

    with patch.object(mac_service, "show", MagicMock(return_value=info)):
        with patch("os.path.exists", MagicMock(return_value=True)):
            assert mac_service._always_running_service(srv_name) is True
Esempio n. 8
0
    def test_service_keep_alive_pathstate_file_rm(self):
        '''
        test _always_running_service when keep_alive
        has pathstate set in plist file and file doesn't exist
        '''
        srv_name = 'com.apple.atrun'
        info = {
            'plist': {
                'EnableTransactions': True,
                'ProgramArguments': ['/usr/libexec/ntpd-wrapper'],
                'Label': 'org.ntp.ntpd',
                'KeepAlive': {
                    'PathState': {
                        '/private/etc/ntp.conf': True
                    }
                }
            }
        }

        with patch.object(mac_service, 'show', MagicMock(return_value=info)):
            with patch('os.path.exists', MagicMock(return_value=False)):
                assert mac_service._always_running_service(srv_name) is False