Example #1
0
    def test_chhomephone(self):
        """
        Change the user's Home Phone
        """
        mock = MagicMock(return_value=False)
        with patch.object(pw_user, "_get_gecos", mock):
            self.assertFalse(pw_user.chhomephone("name", 1))

        mock = MagicMock(return_value={"homephone": "1"})
        with patch.object(pw_user, "_get_gecos", mock):
            self.assertTrue(pw_user.chhomephone("name", 1))

        mock = MagicMock(
            return_value={"homephone": "Unicøde phone number ①③②"})
        with patch.object(pw_user, "_get_gecos", mock):
            self.assertTrue(
                pw_user.chhomephone("name", "Unicøde phone number ①③②"))

        mock = MagicMock(return_value={"homephone": "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={"homephone": "3"})
                with patch.object(pw_user, "info", mock):
                    self.assertFalse(pw_user.chhomephone("name", 1))

        mock = MagicMock(return_value={"homephone": "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={"homephone": "3"})
                with patch.object(pw_user, "info", mock):
                    self.assertFalse(pw_user.chhomephone("name", 1))
Example #2
0
    def test_chhomephone(self):
        '''
        Change the user's Home Phone
        '''
        mock = MagicMock(return_value=False)
        with patch.object(pw_user, '_get_gecos', mock):
            self.assertFalse(pw_user.chhomephone('name', 1))

        mock = MagicMock(return_value={'homephone': '1'})
        with patch.object(pw_user, '_get_gecos', mock):
            self.assertTrue(pw_user.chhomephone('name', 1))

        mock = MagicMock(return_value={'homephone': '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={'homephone': '3'})
                with patch.object(pw_user, 'info', mock):
                    self.assertFalse(pw_user.chhomephone('name', 1))

        mock = MagicMock(return_value={'homephone': '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={'homephone': '3'})
                with patch.object(pw_user, 'info', mock):
                    self.assertFalse(pw_user.chhomephone('name', 1))
Example #3
0
    def test_chhomephone(self):
        '''
        Change the user's Home Phone
        '''
        mock = MagicMock(return_value=False)
        with patch.object(pw_user, '_get_gecos', mock):
            self.assertFalse(pw_user.chhomephone('name', 1))

        mock = MagicMock(return_value={'homephone': '1'})
        with patch.object(pw_user, '_get_gecos', mock):
            self.assertTrue(pw_user.chhomephone('name', 1))

        mock = MagicMock(return_value={'homephone': u'Unicøde phone number ①③②'})
        with patch.object(pw_user, '_get_gecos', mock):
            self.assertTrue(pw_user.chhomephone('name', u'Unicøde phone number ①③②'))

        mock = MagicMock(return_value={'homephone': '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={'homephone': '3'})
                with patch.object(pw_user, 'info', mock):
                    self.assertFalse(pw_user.chhomephone('name', 1))

        mock = MagicMock(return_value={'homephone': '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={'homephone': '3'})
                with patch.object(pw_user, 'info', mock):
                    self.assertFalse(pw_user.chhomephone('name', 1))