def test_get_enabled(self): init_d_globs = ["/etc/init.d/S50foo", "/etc/init.d/S90bar"] glob_mock = MagicMock(side_effect=lambda x: init_d_globs if x == "/etc/rc[S3].d/S*" else DEFAULT) with patch("glob.glob", glob_mock), patch.object(debian_service, "_get_runlevel", MagicMock(return_value="3")): ret = debian_service.get_enabled() expected = ["bar", "foo"] assert ret == expected, ret
def test_get_enabled(self): ''' Test for Return a list of service that are enabled on boot ''' mock_runlevel = MagicMock(return_value=1) mock_prefix = '/etc/rc1.d/S' mock_glob = MagicMock(return_value=[mock_prefix + '01name']) with patch.object(debian_service, '_get_runlevel', mock_runlevel): with patch.object(debian_service.glob, 'glob', mock_glob): self.assertEqual(debian_service.get_enabled()[0], 'name')
def test_get_enabled(self): """ Test for Return a list of service that are enabled on boot """ mock_runlevel = MagicMock(return_value=1) mock_prefix = "/etc/rc1.d/S" mock_glob = MagicMock(return_value=[mock_prefix + "01name"]) with patch.object(debian_service, "_get_runlevel", mock_runlevel): with patch.object(debian_service.glob, "glob", mock_glob): self.assertEqual(debian_service.get_enabled()[0], "name")