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
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
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
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
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
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
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
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