From 427c7147d23fa21c6e8bd08407b1badc48b49c3c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 22 May 2017 16:44:51 +0200 Subject: move everying into sources/pyside2 (5.9 edition) in preparation for a subtree merge. this should not be necessary to do in a separate commit, but git is a tad stupid about following history correctly without it. --- sources/pyside2/tests/QtNetwork/CMakeLists.txt | 7 ++ .../pyside2/tests/QtNetwork/accessManager_test.py | 71 ++++++++++++++++++++ sources/pyside2/tests/QtNetwork/bug_1084.py | 44 ++++++++++++ sources/pyside2/tests/QtNetwork/bug_446.py | 76 +++++++++++++++++++++ .../pyside2/tests/QtNetwork/qipv6address_test.py | 50 ++++++++++++++ sources/pyside2/tests/QtNetwork/tcpserver_test.py | 52 +++++++++++++++ sources/pyside2/tests/QtNetwork/udpsocket_test.py | 78 ++++++++++++++++++++++ 7 files changed, 378 insertions(+) create mode 100644 sources/pyside2/tests/QtNetwork/CMakeLists.txt create mode 100644 sources/pyside2/tests/QtNetwork/accessManager_test.py create mode 100644 sources/pyside2/tests/QtNetwork/bug_1084.py create mode 100644 sources/pyside2/tests/QtNetwork/bug_446.py create mode 100644 sources/pyside2/tests/QtNetwork/qipv6address_test.py create mode 100644 sources/pyside2/tests/QtNetwork/tcpserver_test.py create mode 100644 sources/pyside2/tests/QtNetwork/udpsocket_test.py (limited to 'sources/pyside2/tests/QtNetwork') diff --git a/sources/pyside2/tests/QtNetwork/CMakeLists.txt b/sources/pyside2/tests/QtNetwork/CMakeLists.txt new file mode 100644 index 000000000..f93de5c17 --- /dev/null +++ b/sources/pyside2/tests/QtNetwork/CMakeLists.txt @@ -0,0 +1,7 @@ +PYSIDE_TEST(bug_446.py) +PYSIDE_TEST(bug_1084.py) +PYSIDE_TEST(accessManager_test.py) +# Qt5: QHttp is gone PYSIDE_TEST(http_test.py) +PYSIDE_TEST(tcpserver_test.py) +PYSIDE_TEST(udpsocket_test.py) +PYSIDE_TEST(qipv6address_test.py) diff --git a/sources/pyside2/tests/QtNetwork/accessManager_test.py b/sources/pyside2/tests/QtNetwork/accessManager_test.py new file mode 100644 index 000000000..11b21e841 --- /dev/null +++ b/sources/pyside2/tests/QtNetwork/accessManager_test.py @@ -0,0 +1,71 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +'''Test cases for QHttp''' + +import unittest + +from PySide2.QtCore import * +from PySide2.QtNetwork import * + +from helper import UsesQCoreApplication +from httpd import TestServer + +class AccessManagerCase(UsesQCoreApplication): + + def setUp(self): + super(AccessManagerCase, self).setUp() + self.httpd = TestServer() + self.httpd.start() + self.called = False + + def tearDown(self): + super(AccessManagerCase, self).tearDown() + if self.httpd: + self.httpd.shutdown() + self.httpd = None + + def goAway(self): + self.httpd.shutdown() + self.app.quit() + self.httpd = None + + def slot_replyFinished(self, reply): + self.assertEqual(type(reply), QNetworkReply) + self.called = True + self.goAway() + + def testNetworkRequest(self): + manager = QNetworkAccessManager() + manager.finished.connect(self.slot_replyFinished) + manager.get(QNetworkRequest(QUrl("http://127.0.0.1:%s" % self.httpd.port()))) + self.app.exec_() + self.assertTrue(self.called) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtNetwork/bug_1084.py b/sources/pyside2/tests/QtNetwork/bug_1084.py new file mode 100644 index 000000000..b2d990196 --- /dev/null +++ b/sources/pyside2/tests/QtNetwork/bug_1084.py @@ -0,0 +1,44 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +''' unit test for BUG #1084 ''' + +import unittest +from PySide2 import QtNetwork +import py3kcompat as py3k + +class QTcpSocketTestCase(unittest.TestCase): + def setUp(self): + self.sock = QtNetwork.QTcpSocket() + self.sock.connectToHost('127.0.0.1', 25) + + def testIt(self): + self.sock.write(py3k.unicode_('quit')) + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside2/tests/QtNetwork/bug_446.py b/sources/pyside2/tests/QtNetwork/bug_446.py new file mode 100644 index 000000000..4d3f3c0e9 --- /dev/null +++ b/sources/pyside2/tests/QtNetwork/bug_446.py @@ -0,0 +1,76 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +import unittest + +from PySide2.QtCore import * +from PySide2.QtNetwork import * + +from helper import UsesQCoreApplication + +class HttpSignalsCase(UsesQCoreApplication): + '''Test case for launching QHttp signals''' + DATA = "PySide rocks" + + def onError(self): + self.assertTrue(False) + + def onNewConnection(self): + self.serverConnection = self.server.nextPendingConnection() + self.serverConnection.error.connect(self.onError) + self.serverConnection.write(HttpSignalsCase.DATA) + self.server.close() + + def onReadReady(self): + data = self.client.read(100) + self.assertEqual(data.size(), len(HttpSignalsCase.DATA)) + self.assertEqual(data, HttpSignalsCase.DATA) + self.done() + + def onClientConnect(self): + self.client.readyRead.connect(self.onReadReady) + + def initServer(self): + self.server = QTcpServer() + self.server.newConnection.connect(self.onNewConnection) + self.assertTrue(self.server.listen()) + self.client = QTcpSocket() + self.client.connected.connect(self.onClientConnect) + self.client.connectToHost(QHostAddress(QHostAddress.LocalHost), self.server.serverPort()) + + def done(self): + self.serverConnection.close() + self.client.close() + self.app.quit() + + def testRun(self): + self.initServer() + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtNetwork/qipv6address_test.py b/sources/pyside2/tests/QtNetwork/qipv6address_test.py new file mode 100644 index 000000000..e51760504 --- /dev/null +++ b/sources/pyside2/tests/QtNetwork/qipv6address_test.py @@ -0,0 +1,50 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +'''Test cases for QIPv6Address''' + +import unittest + +from PySide2.QtNetwork import * + +class QIPv6AddressGetItemTest(unittest.TestCase): + def testLength(self): + ip = QIPv6Address() + self.assertEqual(len(ip), 16) + + def testSetItemNegativeIndex(self): + ip = QIPv6Address() + ip[-1] = 8 + self.assertEqual(ip[-1], 8) + + def testSetItemLargeIndex(self): + ip = QIPv6Address() + self.assertRaises(IndexError, ip.__setitem__, 32, 16) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtNetwork/tcpserver_test.py b/sources/pyside2/tests/QtNetwork/tcpserver_test.py new file mode 100644 index 000000000..3c13a1849 --- /dev/null +++ b/sources/pyside2/tests/QtNetwork/tcpserver_test.py @@ -0,0 +1,52 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +'''Test cases for QTCPServer''' + +import unittest + +from PySide2.QtNetwork import QTcpServer + +class ListenDefaultArgsCase(unittest.TestCase): + '''Test case for TcpServer.listen with default args''' + + def setUp(self): + #Acquire resources + self.server = QTcpServer() + + def tearDown(self): + #Release resources + del self.server + + def testDefaultArgs(self): + # @bug 108 + #Default arguments for QTcpServer.listen + self.server.listen() + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtNetwork/udpsocket_test.py b/sources/pyside2/tests/QtNetwork/udpsocket_test.py new file mode 100644 index 000000000..4e3d9ae62 --- /dev/null +++ b/sources/pyside2/tests/QtNetwork/udpsocket_test.py @@ -0,0 +1,78 @@ +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +'''Test cases for QUdpSocket''' + +import unittest + +from PySide2.QtCore import QUrl, QObject, SIGNAL, QCoreApplication, QTimer +from PySide2.QtNetwork import QUdpSocket, QHostAddress + +class HttpSignalsCase(unittest.TestCase): + '''Test case for bug #124 - readDatagram signature + + QUdpSocket.readDatagram must return a tuple with the datagram, host and + port, while receiving only the max payload size.''' + + def setUp(self): + #Acquire resources + self.called = False + self.app = QCoreApplication([]) + + self.socket = QUdpSocket() + + self.server = QUdpSocket() + self.server.bind(QHostAddress(QHostAddress.LocalHost), 45454) + + def tearDown(self): + #Release resources + del self.socket + del self.server + del self.app + + def sendPackage(self): + addr = QHostAddress(QHostAddress.LocalHost) + self.socket.writeDatagram('datagram', addr, 45454) + + def callback(self): + while self.server.hasPendingDatagrams(): + datagram, host, port = self.server.readDatagram(self.server.pendingDatagramSize()) + self.called = True + self.app.quit() + + def testDefaultArgs(self): + #QUdpSocket.readDatagram pythonic return + # @bug 124 + QObject.connect(self.server, SIGNAL('readyRead()'), self.callback) + self.sendPackage() + self.app.exec_() + + self.assertTrue(self.called) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3