コード例 #1
0
ファイル: test_tokens.py プロジェクト: JesRL/mox
    def test_main_returns_1_on_sslerror(self, mock_get_token):
        # Arrange
        args = ['prog', '-u', 'user', '-p', 'pass']

        mock_get_token.side_effect = requests.exceptions.SSLError

        # Act
        with patch.object(sys, 'argv', args):
            actual_code = tokens.main()

        # Assert
        self.assertEqual(1, actual_code)
コード例 #2
0
ファイル: test_tokens.py プロジェクト: JesRL/mox
    def test_main(self, mock_get_token, mock_write):
        # Arrange
        args = ['prog', '-u', 'user', '-p', 'pass']

        mock_get_token.return_value = 'test token'

        # Act
        with patch.object(sys, 'argv', args):
            actual_code = tokens.main()

        # Assert
        self.assertEqual(0, actual_code)
        mock_write.assert_called_with('test token')
コード例 #3
0
ファイル: test_tokens.py プロジェクト: JesRL/mox
    def test_main_insecure_disables_warnings(self, mock_get_token,
                                             mock_urllib3_dw):
        # Arrange
        args = ['prog', '-u', 'user', '-p', 'pass', '--insecure']

        mock_get_token.return_value = 'test token'

        # Act
        with patch.object(sys, 'argv', args):
            actual_code = tokens.main()

        # Assert
        self.assertEqual(0, actual_code)
        mock_urllib3_dw.assert_called()
コード例 #4
0
ファイル: test_tokens.py プロジェクト: JesRL/mox
    def test_main_cert_only(self, mock_get_token, mock_write,
                            mock_base64_decode, mock_ssl_d2p):
        # Arrange
        args = ['prog', '-u', 'user', '-p', 'pass', '--cert-only']

        mock_get_token.return_value = ('<X509Data><X509Certificate>test token'
                                       '</X509Certificate></X509Data>')
        mock_base64_decode.side_effect = lambda x: x
        mock_ssl_d2p.side_effect = lambda x: x

        # Act
        with patch.object(sys, 'argv', args):
            actual_code = tokens.main()

        # Assert
        self.assertEqual(0, actual_code)
        mock_write.assert_called_with('test token')
        mock_base64_decode.assert_called()
        mock_ssl_d2p.assert_called()