def test_chfullname(self): """ Change the user's Full Name """ mock = MagicMock(return_value=False) with patch.object(pw_user, "_get_gecos", mock): self.assertFalse(pw_user.chfullname("name", "fullname")) mock = MagicMock(return_value={"fullname": "fullname"}) with patch.object(pw_user, "_get_gecos", mock): self.assertTrue(pw_user.chfullname("name", "fullname")) mock = MagicMock(return_value={"fullname": "Unicøde name ①③②"}) with patch.object(pw_user, "_get_gecos", mock): self.assertTrue(pw_user.chfullname("name", "Unicøde name ①③②")) mock = MagicMock(return_value={"fullname": "fullname"}) with patch.object(pw_user, "_get_gecos", mock): mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {"cmd.run": mock}): mock = MagicMock(return_value={"fullname": "fullname2"}) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.chfullname("name", "fullname1")) mock = MagicMock(return_value={"fullname": "fullname2"}) with patch.object(pw_user, "_get_gecos", mock): mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {"cmd.run": mock}): mock = MagicMock(return_value={"fullname": "fullname2"}) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.chfullname("name", "fullname1"))
def test_chfullname(self): ''' Change the user's Full Name ''' mock = MagicMock(return_value=False) with patch.object(pw_user, '_get_gecos', mock): self.assertFalse(pw_user.chfullname('name', 'fullname')) mock = MagicMock(return_value={'fullname': 'fullname'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chfullname('name', 'fullname')) mock = MagicMock(return_value={'fullname': 'fullname'}) with patch.object(pw_user, '_get_gecos', mock): mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(return_value={'fullname': 'fullname2'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chfullname('name', 'fullname1')) mock = MagicMock(return_value={'fullname': 'fullname2'}) with patch.object(pw_user, '_get_gecos', mock): mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(return_value={'fullname': 'fullname2'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chfullname('name', 'fullname1'))
def test_chfullname(self): ''' Change the user's Full Name ''' mock = MagicMock(return_value=False) with patch.object(pw_user, '_get_gecos', mock): self.assertFalse(pw_user.chfullname('name', 'fullname')) mock = MagicMock(return_value={'fullname': 'fullname'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chfullname('name', 'fullname')) mock = MagicMock(return_value={'fullname': u'Unicøde name ①③②'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chfullname('name', u'Unicøde name ①③②')) mock = MagicMock(return_value={'fullname': 'fullname'}) with patch.object(pw_user, '_get_gecos', mock): mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(return_value={'fullname': 'fullname2'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chfullname('name', 'fullname1')) mock = MagicMock(return_value={'fullname': 'fullname2'}) with patch.object(pw_user, '_get_gecos', mock): mock = MagicMock(return_value=None) with patch.dict(pw_user.__salt__, {'cmd.run': mock}): mock = MagicMock(return_value={'fullname': 'fullname2'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chfullname('name', 'fullname1'))