Ejemplo n.º 1
0
    def test_debian(self):
        with mock.patch.multiple('os.path',
                                 isdir=lambda x: x == '/run/systemd/system'):
            self.assertEqual('systemd', debian.choose_init())

        def mock_call_with_upstart(*args, **kwargs):
            if args[0] == '. /lib/lsb/init-functions ; init_is_upstart' and \
               kwargs['shell']:
                return 0
            else:
                return 1

        with mock.patch.multiple('os.path',
                                 isdir=lambda x: False,
                                 isfile=lambda x: False):
            with mock.patch.multiple('subprocess',
                                     call=mock_call_with_upstart):
                self.assertEqual('upstart', debian.choose_init())
        with mock.patch.multiple('os.path',
                                 isdir=lambda x: False,
                                 isfile=lambda x: x == '/sbin/init',
                                 islink=lambda x: x != '/sbin/init'):
            with mock.patch.multiple('subprocess',
                                     call=lambda *args, **kwargs: 1):
                self.assertEqual('sysvinit', debian.choose_init())
        with mock.patch.multiple('os.path',
                                 isdir=lambda x: False,
                                 isfile=lambda x: False):
            with mock.patch.multiple('subprocess',
                                     call=lambda *args, **kwargs: 1):
                self.assertIs(None, debian.choose_init())
Ejemplo n.º 2
0
    def test_debian(self):
        with mock.patch.multiple('os.path',
                                 isdir=lambda x: x == '/run/systemd/system'):
            self.assertEqual('systemd', debian.choose_init())

        def mock_call_with_upstart(*args, **kwargs):
            if args[0] == '. /lib/lsb/init-functions ; init_is_upstart' and \
               kwargs['shell']:
                return 0
            else:
                return 1
        with mock.patch.multiple('os.path',
                                 isdir=lambda x: False,
                                 isfile=lambda x: False):
            with mock.patch.multiple('subprocess',
                                     call=mock_call_with_upstart):
                self.assertEqual('upstart', debian.choose_init())
        with mock.patch.multiple('os.path',
                                 isdir=lambda x: False,
                                 isfile=lambda x: x == '/sbin/init',
                                 islink=lambda x: x != '/sbin/init'):
            with mock.patch.multiple('subprocess',
                                     call=lambda *args, **kwargs: 1):
                self.assertEqual('sysvinit', debian.choose_init())
        with mock.patch.multiple('os.path',
                                 isdir=lambda x: False,
                                 isfile=lambda x: False):
            with mock.patch.multiple('subprocess',
                                     call=lambda *args, **kwargs: 1):
                self.assertIs(None, debian.choose_init())
Ejemplo n.º 3
0
 def test_debian(self):
     with mock.patch('ceph_detect_init.debian.distro',
                     'debian'):
         self.assertEqual('sysvinit', debian.choose_init())
     with mock.patch('ceph_detect_init.debian.distro',
                     'ubuntu'):
         self.assertEqual('upstart', debian.choose_init())
Ejemplo n.º 4
0
 def test_debian(self):
     with mock.patch.multiple('ceph_detect_init.debian',
                              distro='debian',
                              codename='wheezy'):
         self.assertEqual('sysvinit', debian.choose_init())
     with mock.patch.multiple('ceph_detect_init.debian',
                              distro='ubuntu',
                              codename='trusty'):
         self.assertEqual('upstart', debian.choose_init())
     with mock.patch.multiple('ceph_detect_init.debian',
                              distro='ubuntu',
                              codename='vivid'):
         self.assertEqual('systemd', debian.choose_init())
Ejemplo n.º 5
0
 def test_debian(self):
     with mock.patch.multiple('ceph_detect_init.debian',
                              distro='debian',
                              codename='wheezy'):
         self.assertEqual('sysvinit', debian.choose_init())
     with mock.patch.multiple('ceph_detect_init.debian',
                              distro='ubuntu',
                              codename='trusty'):
         self.assertEqual('upstart', debian.choose_init())
     with mock.patch.multiple('ceph_detect_init.debian',
                              distro='ubuntu',
                              codename='vivid'):
         self.assertEqual('systemd', debian.choose_init())