コード例 #1
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'])
コード例 #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"])