예제 #1
0
    def test_chshell(self):
        """
        Test if shell given is same as previous shell
        """
        mock = MagicMock(return_value={"shell": "A"})
        with patch.object(pw_user, "info", mock):
            self.assertTrue(pw_user.chshell("name", "A"))

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

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {"cmd.run": mock}):
            mock = MagicMock(side_effect=[{"shell": "A"}, {"shell": "B"}])
            with patch.object(pw_user, "info", mock):
                self.assertTrue(pw_user.chshell("name", "A"))
예제 #2
0
파일: pw_user_test.py 프로젝트: DaveQB/salt
    def test_chshell(self):
        '''
        Test if shell given is same as previous shell
        '''
        mock = MagicMock(return_value={'shell': 'A'})
        with patch.object(pw_user, 'info', mock):
            self.assertTrue(pw_user.chshell('name', 'A'))

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

        mock = MagicMock(return_value=None)
        with patch.dict(pw_user.__salt__, {'cmd.run': mock}):
            mock = MagicMock(side_effect=[{'shell': 'A'}, {'shell': 'B'}])
            with patch.object(pw_user, 'info', mock):
                self.assertTrue(pw_user.chshell('name', 'A'))
예제 #3
0
    def test_chshell(self):
        '''
        Test if shell given is same as previous shell
        '''
        mock = MagicMock(return_value={'shell': 'A'})
        with patch.object(pw_user, 'info', mock):
            self.assertTrue(pw_user.chshell('name', 'A'))

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

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