def test_restart(self): ''' Test to restart the named service ''' with patch.dict(smf.__salt__, {'cmd.retcode': MagicMock(side_effect=[False, True])}): with patch.object(smf, 'start', return_value='A'): self.assertEqual(smf.restart('name'), 'A') self.assertFalse(smf.restart('name'))