예제 #1
0
    def test_close(self):
        connection = Mock()
        connection.close.side_effect = ValueError

        # test
        sender = Sender(None)
        sender.connection = connection
        sender.is_open = Mock(return_value=True)
        sender.close()

        # validation
        self.assertFalse(connection.close.called)
예제 #2
0
    def test_repair(self, connection):
        url = 'test-url'

        # test
        sender = Sender(url)
        sender.close = Mock()
        sender.repair()

        # validation
        sender.connection.close.assert_called_once_with()
        sender.close.assert_called_once_with()
        connection.return_value.open.assert_called_once_with()