diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-04-28 16:03:32 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-04-28 16:03:50 +0200 |
commit | 6ed3917b214e0d1a54bb316304bcf562c802e633 (patch) | |
tree | 6e3178ddc088dd6ec0bb51f1c9fa67a22f84627b | |
parent | a04bd319f9ac7aebb0400ceca8bc593e04d749a8 (diff) | |
parent | 9b2bab68c96c22f152120c58b4ff5cb01e24a620 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: Ib69b7af46e48558e9e67dde80fceeb0dcec1ca38
-rw-r--r-- | PySide2/QtCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | PySide2/QtCore/typesystem_core_common.xml | 1 | ||||
-rw-r--r-- | tests/QtCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtCore/qurl_test.py | 91 | ||||
-rw-r--r-- | tests/QtCore/qurlquery_test.py | 59 |
5 files changed, 105 insertions, 48 deletions
diff --git a/PySide2/QtCore/CMakeLists.txt b/PySide2/QtCore/CMakeLists.txt index 77e304c3..9eec8978 100644 --- a/PySide2/QtCore/CMakeLists.txt +++ b/PySide2/QtCore/CMakeLists.txt @@ -134,6 +134,7 @@ ${QtCore_GEN_DIR}/qtimer_wrapper.cpp ${QtCore_GEN_DIR}/qtimerevent_wrapper.cpp ${QtCore_GEN_DIR}/qtranslator_wrapper.cpp ${QtCore_GEN_DIR}/qurl_wrapper.cpp +${QtCore_GEN_DIR}/qurlquery_wrapper.cpp ${QtCore_GEN_DIR}/qvariantanimation_wrapper.cpp ${QtCore_GEN_DIR}/qwaitcondition_wrapper.cpp ${QtCore_GEN_DIR}/qwritelocker_wrapper.cpp diff --git a/PySide2/QtCore/typesystem_core_common.xml b/PySide2/QtCore/typesystem_core_common.xml index a15547a4..dfce090e 100644 --- a/PySide2/QtCore/typesystem_core_common.xml +++ b/PySide2/QtCore/typesystem_core_common.xml @@ -2330,6 +2330,7 @@ <include file-name="QSize" location="global"/> </extra-includes> </object-type> + <value-type name="QUrlQuery" since="5.0" /> <value-type name="QUrl" hash-function="PySide::hash"> <!-- Qt5: lots of changes --> <enum-type name="ComponentFormattingOption" flags="ComponentFormattingOptions,FormattingOptions"/> diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 5771e10f..cbb7c5f2 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -103,6 +103,7 @@ PYSIDE_TEST(qtimer_singleshot_test.py) PYSIDE_TEST(qtimer_timeout_test.py) PYSIDE_TEST(qtnamespace_test.py) PYSIDE_TEST(qurl_test.py) +PYSIDE_TEST(qurlquery_test.py) PYSIDE_TEST(repr_test.py) PYSIDE_TEST(setprop_on_ctor_test.py) PYSIDE_TEST(staticMetaObject_test.py) diff --git a/tests/QtCore/qurl_test.py b/tests/QtCore/qurl_test.py index 9d0327af..325227b4 100644 --- a/tests/QtCore/qurl_test.py +++ b/tests/QtCore/qurl_test.py @@ -33,6 +33,7 @@ import unittest from PySide2.QtCore import QUrl +from PySide2.QtCore import QUrlQuery class QUrlBasicConstructor(unittest.TestCase): '''Tests the basic constructors''' @@ -67,54 +68,48 @@ class QUrlBasicConstructor(unittest.TestCase): self.assertEqual(url.toString(), 'ftp://john:abc123@www.google.com:8080/mail/view') -# PYSIDE-345: No bindings for QUrlQuery -# class QueryItemsTest(unittest.TestCase): -# '''Test query item management''' -# -# def testQueryItems(self): -# #QUrl.queryItems -# url = QUrl('http://www.google.com/search?q=python&hl=en') -# valid_data = [(('q'), ('python')), (('hl'), ('en'))] -# -# self.assertEqual(sorted(url.queryItems()), sorted(valid_data)) -# -# def testEncodedQueryItems(self): -# #QUrl.encodedQueryItems -# url = QUrl('http://www.google.com/search?q=python&hl=en') -# valid_data = [(('q'), ('python')), (('hl'), ('en'))] -# -# self.assertEqual(sorted(url.encodedQueryItems()), sorted(valid_data)) -# -# def testSetQueryItems(self): -# #QUrl.setQueryItems -# urla = QUrl('http://www.google.com/search?q=python&hl=en') -# urlb = QUrl('http://www.google.com/search') -# -# urlb.setQueryItems(urla.queryItems()) -# -# self.assertEqual(urla, urlb) -# -# def testAddQueryItem(self): -# #QUrl.addQueryItem -# url = QUrl() -# valid_data = [('hl', 'en'), ('user', 'konqui')] -# -# url.addQueryItem(*valid_data[0]) -# self.assertEqual(url.queryItems()[0], valid_data[0]) -# -# url.addQueryItem(*valid_data[1]) -# self.assertEqual(sorted(url.queryItems()), sorted(valid_data)) -# -# def testAllEncodedQueryItemsValues(self): -# #QUrl.allEncodedQueryItemValues -# url = QUrl() -# key = 'key' -# valid_data = ['data', 'valid', 'test'] -# -# for i, data in enumerate(valid_data): -# url.addQueryItem(key, data) -# self.assertEqual(url.allEncodedQueryItemValues(key), -# list(valid_data[:i+1])) +class QueryItemsTest(unittest.TestCase): + '''Test query item management''' + + def testQueryItems(self): + url = QUrl('http://www.google.com/search?q=python&hl=en') + valid_data = [(('q'), ('python')), (('hl'), ('en'))] + + self.assertEqual(sorted(QUrlQuery(url.query()).queryItems()), sorted(valid_data)) + + def testEncodedQueryItems(self): + url = QUrl('http://www.google.com/search?q=python&hl=en') + valid_data = [(('q'), ('python')), (('hl'), ('en'))] + + self.assertEqual(sorted(QUrlQuery(url.query()).queryItems()), sorted(valid_data)) + + def testSetQueryItems(self): + urla = QUrl('http://www.google.com/search?q=python&hl=en') + urlb = QUrl('http://www.google.com/search') + + urlb.setQuery(urla.query()) + + self.assertEqual(urla, urlb) + + def testAddQueryItem(self): + url = QUrlQuery() + valid_data = [('hl', 'en'), ('user', 'konqui')] + + url.addQueryItem(*valid_data[0]) + self.assertEqual(url.queryItems()[0], valid_data[0]) + + url.addQueryItem(*valid_data[1]) + self.assertEqual(sorted(url.queryItems()), sorted(valid_data)) + + def testAllQueryItemsValues(self): + url = QUrlQuery() + key = 'key' + valid_data = ['data', 'valid', 'test'] + + for i, data in enumerate(valid_data): + url.addQueryItem(key, data) + self.assertEqual(url.allQueryItemValues(key), + list(valid_data[:i+1])) if __name__ == '__main__': diff --git a/tests/QtCore/qurlquery_test.py b/tests/QtCore/qurlquery_test.py new file mode 100644 index 00000000..e42856e6 --- /dev/null +++ b/tests/QtCore/qurlquery_test.py @@ -0,0 +1,59 @@ +#!/usr/bin/python + +############################################################################# +## +## Copyright (C) 2017 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 tests for QUrlQuery''' + +import unittest +import ctypes +import sys + +from PySide2.QtCore import QUrlQuery + +class QUrlQueryTest(unittest.TestCase): + def testConstructing(self): + empty = QUrlQuery() + self.assertTrue(empty.isEmpty()) + self.assertEqual(empty.queryPairDelimiter(), QUrlQuery.defaultQueryPairDelimiter()) + self.assertEqual(empty.queryValueDelimiter(), QUrlQuery.defaultQueryValueDelimiter()) + + empty.clear(); + self.assertTrue(empty.isEmpty()) + + def testAddRemove(self): + query = QUrlQuery() + + query.addQueryItem("a", "b"); + self.assertTrue(not query.isEmpty()) + self.assertTrue(query.hasQueryItem("a")) + self.assertEqual(query.queryItemValue("a"), "b") + self.assertEqual(query.allQueryItemValues("a"), ["b"]) + +if __name__ == '__main__': + unittest.main() |