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>
This commit is contained in:
parent
5ce7c94536
commit
88146cf500
4 changed files with 118 additions and 32 deletions
38
tests/QtNetwork/basic_auth_test.py
Normal file
38
tests/QtNetwork/basic_auth_test.py
Normal file
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue