def test_chworkphone(self): """ Change the user's Work Phone """ mock = MagicMock(return_value=False) with patch.object(pw_user, "_get_gecos", mock): self.assertFalse(pw_user.chworkphone("name", 1)) mock = MagicMock(return_value={"workphone": "1"}) with patch.object(pw_user, "_get_gecos", mock): self.assertTrue(pw_user.chworkphone("name", 1)) mock = MagicMock( return_value={"workphone": "Unicøde phone number ①③②"}) with patch.object(pw_user, "_get_gecos", mock): self.assertTrue( pw_user.chworkphone("name", "Unicøde phone number ①③②")) mock = MagicMock(return_value={"workphone": "2"}) 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={"workphone": "3"}) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.chworkphone("name", 1)) mock = MagicMock(return_value={"workphone": "3"}) 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={"workphone": "3"}) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.chworkphone("name", 1))
def test_chworkphone(self): ''' Change the user's Work Phone ''' mock = MagicMock(return_value=False) with patch.object(pw_user, '_get_gecos', mock): self.assertFalse(pw_user.chworkphone('name', 1)) mock = MagicMock(return_value={'workphone': '1'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chworkphone('name', 1)) mock = MagicMock(return_value={'workphone': '2'}) 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={'workphone': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chworkphone('name', 1)) mock = MagicMock(return_value={'workphone': '3'}) 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={'workphone': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chworkphone('name', 1))
def test_chworkphone(self): ''' Change the user's Work Phone ''' mock = MagicMock(return_value=False) with patch.object(pw_user, '_get_gecos', mock): self.assertFalse(pw_user.chworkphone('name', 1)) mock = MagicMock(return_value={'workphone': '1'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chworkphone('name', 1)) mock = MagicMock(return_value={'workphone': u'Unicøde phone number ①③②'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chworkphone('name', u'Unicøde phone number ①③②')) mock = MagicMock(return_value={'workphone': '2'}) 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={'workphone': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chworkphone('name', 1)) mock = MagicMock(return_value={'workphone': '3'}) 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={'workphone': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chworkphone('name', 1))