aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtNetwork/basic_auth_test.py
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/basic_auth_test.py
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/basic_auth_test.py')
-rw-r--r--tests/QtNetwork/basic_auth_test.py38
1 files changed, 38 insertions, 0 deletions
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()