aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtNetwork
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-18 16:11:54 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-06-18 17:37:29 -0300
commit88146cf500008c13912e03213dc98bab491b15a2 (patch)
tree781bff12afbd9b962225e820dc1a1d237e49453d /tests/QtNetwork
parent5ce7c945367f1d673a25666c1cc3ab300b23df49 (diff)
Implemented a dummy http server to run unit-test on a offline computer.
Reviewed: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/QtNetwork')
-rw-r--r--tests/QtNetwork/CMakeLists.txt2
-rw-r--r--tests/QtNetwork/basic_auth_test.py38
-rw-r--r--tests/QtNetwork/http_test.py39
3 files changed, 47 insertions, 32 deletions
diff --git a/tests/QtNetwork/CMakeLists.txt b/tests/QtNetwork/CMakeLists.txt
index cae147080..0eb503714 100644
--- a/tests/QtNetwork/CMakeLists.txt
+++ b/tests/QtNetwork/CMakeLists.txt
@@ -1,3 +1,5 @@
+
+PYSIDE_TEST(basic_auth_test.py)
PYSIDE_TEST(accessManager_test.py)
PYSIDE_TEST(http_test.py)
PYSIDE_TEST(tcpserver_test.py)
diff --git a/tests/QtNetwork/basic_auth_test.py b/tests/QtNetwork/basic_auth_test.py
new file mode 100644
index 000000000..8087eeda6
--- /dev/null
+++ b/tests/QtNetwork/basic_auth_test.py
@@ -0,0 +1,38 @@
+import unittest
+
+from PySide.QtCore import *
+from PySide.QtNetwork import *
+
+from helper import UsesQApplication
+from httpd import TestServer
+
+class testAuthenticationSignal(UsesQApplication):
+
+ def setUp(self):
+ super(testAuthenticationSignal, self).setUp()
+ self.httpd = TestServer(secure=True)
+ self.httpd.start()
+ self._resultOk = False
+
+ def tearDown(self):
+ self.httpd.shutdown()
+ del self.httpd
+ super(testAuthenticationSignal, self).tearDown()
+
+ def onAuthRequest(self, hostname, port, auth):
+ self.assert_(isinstance(auth, QAuthenticator))
+ self._resultOk = True
+ self.app.quit()
+
+
+ def testwaitSignal(self):
+ http = QHttp()
+ http.setHost("localhost", self.httpd.port())
+ http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest)
+ path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
+ data = http.get(path)
+ self.app.exec_()
+ self.assert_(self._resultOk)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/QtNetwork/http_test.py b/tests/QtNetwork/http_test.py
index 379ff5dfb..5d40405a9 100644
--- a/tests/QtNetwork/http_test.py
+++ b/tests/QtNetwork/http_test.py
@@ -7,24 +7,27 @@ from PySide.QtCore import *
from PySide.QtNetwork import *
from helper import UsesQApplication
+from httpd import TestServer
-"""
class HttpSignalsCase(UsesQApplication):
'''Test case for launching QHttp signals'''
def setUp(self):
super(HttpSignalsCase, self).setUp()
-
self.http = QHttp()
- self.url = QUrl('http://www.google.com')
- self.timer = QTimer.singleShot(250, self.app.quit)
+ self.httpd = TestServer()
+ self.httpd.start()
+ self.url = QUrl('localhost:' + str(self.httpd.port()))
+ self.called = False
def tearDown(self):
+ self.httpd.shutdown()
del self.http
super(HttpSignalsCase, self).tearDown()
def callback(self, ident):
self.called = True
+ self.app.quit()
def testDefaultArgs(self):
#QHttp signal requestStarted signal
@@ -35,33 +38,5 @@ class HttpSignalsCase(UsesQApplication):
self.app.exec_()
self.assert_(self.called)
-class testHttp(UsesQApplication):
- def testRead(self):
- header = QHttpRequestHeader("GET", QString(QUrl.toPercentEncoding("/index.html")))
- header.setValue("Host", "qtsoftware.com");
- http = QHttp()
- http.setHost("qtsoftware.com")
- http.request(header)
- data = http.read(100)
-"""
-
-class testAuthenticationSignal(UsesQApplication):
- def onAuthRequest(self, hostname, port, auth):
- self.assert_(isinstance(auth, QAuthenticator))
- print auth.realm()
- self._resultOk = True
- self.app.exit()
-
- def testwaitSignal(self):
- self._resultOk = False
- http = QHttp()
- http.setHost("projects.maemo.org", QHttp.ConnectionModeHttps, 0)
- http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest)
- path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
- print http.get(path)
- self.app.exec_()
- self.assert_(self._resultOk)
-
-
if __name__ == '__main__':
unittest.main()