def test_chuid(self):
        """
        Test if user id given is same as previous id
        """
        mock = MagicMock(return_value={"uid": "A"})
        with patch.object(pw_user, "info", mock):
            self.assertTrue(pw_user.chuid("name", "A"))

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {"cmd.run": mock}):
            mock = MagicMock(side_effect=[{"uid": "A"}, {"uid": "A"}])
            with patch.object(pw_user, "info", mock):
                self.assertFalse(pw_user.chuid("name", "B"))

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {"cmd.run": mock}):
            mock = MagicMock(side_effect=[{"uid": "A"}, {"uid": "B"}])
            with patch.object(pw_user, "info", mock):
                self.assertTrue(pw_user.chuid("name", "A"))
Beispiel #2
0
    def test_chuid(self):
        '''
        Test if user id given is same as previous id
        '''
        mock = MagicMock(return_value={'uid': 'A'})
        with patch.object(pw_user, 'info', mock):
            self.assertTrue(pw_user.chuid('name', 'A'))

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {'cmd.run': mock}):
            mock = MagicMock(side_effect=[{'uid': 'A'}, {'uid': 'A'}])
            with patch.object(pw_user, 'info', mock):
                self.assertFalse(pw_user.chuid('name', 'B'))

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {'cmd.run': mock}):
            mock = MagicMock(side_effect=[{'uid': 'A'}, {'uid': 'B'}])
            with patch.object(pw_user, 'info', mock):
                self.assertTrue(pw_user.chuid('name', 'A'))
Beispiel #3
0
    def test_chuid(self):
        '''
        Test if user id given is same as previous id
        '''
        mock = MagicMock(return_value={'uid': 'A'})
        with patch.object(pw_user, 'info', mock):
            self.assertTrue(pw_user.chuid('name', 'A'))

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {'cmd.run': mock}):
            mock = MagicMock(side_effect=[{'uid': 'A'}, {'uid': 'A'}])
            with patch.object(pw_user, 'info', mock):
                self.assertFalse(pw_user.chuid('name', 'B'))

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {'cmd.run': mock}):
            mock = MagicMock(side_effect=[{'uid': 'A'}, {'uid': 'B'}])
            with patch.object(pw_user, 'info', mock):
                self.assertTrue(pw_user.chuid('name', 'A'))