コード例 #1
0
 def test_get_all(self):
     '''
         Test to return a list of all available services
     '''
     mock = MagicMock(return_value={"a": "enabled", "b": "enabled",
                                    "c": "disabled"})
     with patch.object(systemd, '_get_all_units', mock):
         mock = MagicMock(return_value={"a1": "enabled", "b1": "disabled",
                                        "c1": "enabled"})
         with patch.object(systemd, '_get_all_unit_files', mock):
             mock = MagicMock(return_value={})
             with patch.object(systemd,
                               '_get_all_legacy_init_scripts', mock):
                 self.assertListEqual(systemd.get_all(),
                                      ['a', 'a1', 'b', 'b1', 'c', 'c1'])
コード例 #2
0
 def test_get_all(self):
     '''
     Test to return a list of all available services
     '''
     listdir_mock = MagicMock(side_effect=[[
         'foo.service', 'multi-user.target.wants', 'mytimer.timer'
     ], [], ['foo.service', 'multi-user.target.wants', 'bar.service'],
                                           ['mysql', 'nginx', 'README']])
     access_mock = MagicMock(side_effect=lambda x, y: x != os.path.join(
         systemd.INITSCRIPT_PATH, 'README'))
     with patch.object(os, 'listdir', listdir_mock):
         with patch.object(os, 'access', side_effect=access_mock):
             self.assertListEqual(
                 systemd.get_all(),
                 ['bar', 'foo', 'mysql', 'mytimer.timer', 'nginx'])
コード例 #3
0
ファイル: systemd_test.py プロジェクト: bryson/salt
 def test_get_all(self):
     '''
     Test to return a list of all available services
     '''
     listdir_mock = MagicMock(side_effect=[
         ['foo.service', 'multi-user.target.wants', 'mytimer.timer'],
         ['foo.service', 'multi-user.target.wants', 'bar.service'],
         ['mysql', 'nginx', 'README'],
         ['mysql', 'nginx', 'README']
     ])
     access_mock = MagicMock(
         side_effect=lambda x, y: x != os.path.join(
             systemd.INITSCRIPT_PATH,
             'README'
         )
     )
     with patch.object(os, 'listdir', listdir_mock):
         with patch.object(os, 'access', side_effect=access_mock):
             self.assertListEqual(
                 systemd.get_all(),
                 ['bar', 'foo', 'mysql', 'mytimer.timer', 'nginx']
             )