|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# This file is part of IRC Bot Behavior Bundle (IB3) |
| 4 | +# Copyright (C) 2017 Bryan Davis and contributors |
| 5 | +# |
| 6 | +# This program is free software: you can redistribute it and/or modify it |
| 7 | +# under the terms of the GNU General Public License as published by the Free |
| 8 | +# Software Foundation, either version 3 of the License, or (at your option) |
| 9 | +# any later version. |
| 10 | +# |
| 11 | +# This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | +# more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License along with |
| 17 | +# this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +try: |
| 20 | + from unittest import mock |
| 21 | +except ImportError: |
| 22 | + import mock |
| 23 | + |
| 24 | +import ssl |
| 25 | + |
| 26 | +import ib3 |
| 27 | +import ib3.connection |
| 28 | + |
| 29 | + |
| 30 | +class SSLBot(ib3.connection.SSL, ib3.Bot): |
| 31 | + pass |
| 32 | + |
| 33 | + |
| 34 | +@mock.patch('irc.bot.SingleServerIRCBot.__init__') |
| 35 | +@mock.patch('irc.connection.Factory') |
| 36 | +def test_ssl(conn_factory, mock_init): |
| 37 | + bot = SSLBot( |
| 38 | + server_list=[('localhost', '9999')], |
| 39 | + realname='ib3test', |
| 40 | + nickname='ib3test', |
| 41 | + ) |
| 42 | + assert isinstance(bot, ib3.connection.SSL) |
| 43 | + assert isinstance(bot, ib3.Bot) |
| 44 | + conn_factory.assert_called_once_with(wrapper=ssl.wrap_socket) |
| 45 | + args, kwargs = mock_init.call_args |
| 46 | + assert kwargs['connect_factory'] is conn_factory.return_value |
0 commit comments