def test_chroomnumber(self): """ Change the user's Room Number """ mock = MagicMock(return_value=False) with patch.object(pw_user, "_get_gecos", mock): self.assertFalse(pw_user.chroomnumber("name", 1)) mock = MagicMock(return_value={"roomnumber": "Unicøde room ①③②"}) with patch.object(pw_user, "_get_gecos", mock): self.assertTrue(pw_user.chroomnumber("name", "Unicøde room ①③②")) mock = MagicMock(return_value={"roomnumber": "1"}) with patch.object(pw_user, "_get_gecos", mock): self.assertTrue(pw_user.chroomnumber("name", 1)) mock = MagicMock(return_value={"roomnumber": "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={"roomnumber": "3"}) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.chroomnumber("name", 1)) mock = MagicMock(return_value={"roomnumber": "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={"roomnumber": "3"}) with patch.object(pw_user, "info", mock): self.assertFalse(pw_user.chroomnumber("name", 1))
def test_chroomnumber(self): ''' Change the user's Room Number ''' mock = MagicMock(return_value=False) with patch.object(pw_user, '_get_gecos', mock): self.assertFalse(pw_user.chroomnumber('name', 1)) mock = MagicMock(return_value={'roomnumber': '1'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chroomnumber('name', 1)) mock = MagicMock(return_value={'roomnumber': '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={'roomnumber': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chroomnumber('name', 1)) mock = MagicMock(return_value={'roomnumber': '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={'roomnumber': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chroomnumber('name', 1))
def test_chroomnumber(self): ''' Change the user's Room Number ''' mock = MagicMock(return_value=False) with patch.object(pw_user, '_get_gecos', mock): self.assertFalse(pw_user.chroomnumber('name', 1)) mock = MagicMock(return_value={'roomnumber': u'Unicøde room ①③②'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chroomnumber('name', u'Unicøde room ①③②')) mock = MagicMock(return_value={'roomnumber': '1'}) with patch.object(pw_user, '_get_gecos', mock): self.assertTrue(pw_user.chroomnumber('name', 1)) mock = MagicMock(return_value={'roomnumber': '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={'roomnumber': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chroomnumber('name', 1)) mock = MagicMock(return_value={'roomnumber': '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={'roomnumber': '3'}) with patch.object(pw_user, 'info', mock): self.assertFalse(pw_user.chroomnumber('name', 1))