コード例 #1
0
ファイル: http_test.py プロジェクト: donfaco/pyside2
class HttpSignalsCase(UsesQCoreApplication):
    '''Test case for launching QHttp signals'''

    def setUp(self):
        super(HttpSignalsCase, self).setUp()
        self.httpd = TestServer()
        self.httpd.start()
        self.http = QHttp("127.0.0.1" , self.httpd.port())
        self.called = False

    def tearDown(self):
        if self.httpd:
            self.httpd.shutdown()
            del self.httpd
        self.http = None
        self.httpd = None
        super(HttpSignalsCase, self).tearDown()

    def goAway(self):
        self.httpd.shutdown()
        self.app.quit()

    def callback(self, ident):
        self.called = True
        self.goAway()

    def testDefaultArgs(self):
        #QHttp signal requestStarted signal
        # @bug 114
        self.http.requestStarted.connect(self.callback)
        self.http.get("index.html")
        self.app.exec_()
        self.assert_(self.called)
コード例 #2
0
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.assert_(self.called)
コード例 #3
0
class HttpSignalsCase(UsesQCoreApplication):
    '''Test case for launching QHttp signals'''
    def setUp(self):
        super(HttpSignalsCase, self).setUp()
        self.httpd = TestServer()
        self.httpd.start()
        self.http = QHttp("127.0.0.1", self.httpd.port())
        self.called = False

    def tearDown(self):
        if self.httpd:
            self.httpd.shutdown()
            del self.httpd
        self.http = None
        self.httpd = None
        super(HttpSignalsCase, self).tearDown()

    def goAway(self):
        self.httpd.shutdown()
        self.app.quit()

    def callback(self, ident):
        self.called = True
        self.goAway()

    def testDefaultArgs(self):
        #QHttp signal requestStarted signal
        # @bug 114
        self.http.requestStarted.connect(self.callback)
        self.http.get("index.html")
        self.app.exec_()
        self.assert_(self.called)
コード例 #4
0
ファイル: accessManager_test.py プロジェクト: Hasimir/PySide
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.assert_(self.called)
コード例 #5
0
class testAuthenticationSignal(UsesQCoreApplication):
    def setUp(self):
        super(testAuthenticationSignal, self).setUp()
        self.httpd = TestServer(secure=True)
        self.httpd.start()
        self._resultOk = False

    def tearDown(self):
        if self.httpd:
            self.httpd.shutdown()
            del self.httpd
        super(testAuthenticationSignal, self).tearDown()

    def goAway(self):
        self.httpd.shutdown()
        self.app.quit()
        self.httpd = None

    def onAuthRequest(self, hostname, port, auth):
        self.assertTrue(isinstance(auth, QAuthenticator))
        self._resultOk = True
        self.goAway()

    def testwaitSignal(self):
        http = QHttp('127.0.0.1', self.httpd.port())
        http.connect(
            SIGNAL(
                "authenticationRequired(const QString&, quint16, QAuthenticator*)"
            ), self.onAuthRequest)
        path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
        data = http.get(str(path))
        self.app.exec_()
        self.assertTrue(self._resultOk)

    def testwaitSignal2(self):
        http = QHttp('127.0.0.1', self.httpd.port())
        # Using new signal slot syntax causes a segfault
        http.authenticationRequired.connect(self.onAuthRequest)
        path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
        data = http.get(str(path))
        self.app.exec_()
        self.assertTrue(self._resultOk)
コード例 #6
0
class testAuthenticationSignal(UsesQCoreApplication):

    def setUp(self):
        super(testAuthenticationSignal, self).setUp()
        self.httpd = TestServer(secure=True)
        self.httpd.start()
        self._resultOk = False

    def tearDown(self):
        if self.httpd:
            self.httpd.shutdown()
            del self.httpd
        super(testAuthenticationSignal, self).tearDown()

    def goAway(self):
        self.httpd.shutdown()
        self.app.quit()
        self.httpd = None

    def onAuthRequest(self, hostname, port, auth):
        self.assertTrue(isinstance(auth, QAuthenticator))
        self._resultOk = True
        self.goAway()

    def testwaitSignal(self):
        http = QHttp('127.0.0.1', self.httpd.port())
        http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest)
        path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
        data = http.get(str(path))
        self.app.exec_()
        self.assertTrue(self._resultOk)

    def testwaitSignal2(self):
        http = QHttp('127.0.0.1', self.httpd.port())
        # Using new signal slot syntax causes a segfault
        http.authenticationRequired.connect(self.onAuthRequest)
        path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/")
        data = http.get(str(path))
        self.app.exec_()
        self.assertTrue(self._resultOk)
コード例 #7
0
 def setUp(self):
     super(AccessManagerCase, self).setUp()
     self.httpd = TestServer()
     self.httpd.start()
     self.called = False
コード例 #8
0
 def setUp(self):
     super(testAuthenticationSignal, self).setUp()
     self.httpd = TestServer(secure=True)
     self.httpd.start()
     self._resultOk = False
コード例 #9
0
 def setUp(self):
     super(HttpSignalsCase, self).setUp()
     self.httpd = TestServer()
     self.httpd.start()
     self.http = QHttp("127.0.0.1", self.httpd.port())
     self.called = False
コード例 #10
0
 def setUp(self):
     super(testAuthenticationSignal, self).setUp()
     self.httpd = TestServer(secure=True)
     self.httpd.start()
     self._resultOk = False
コード例 #11
0
ファイル: http_test.py プロジェクト: donfaco/pyside2
 def setUp(self):
     super(HttpSignalsCase, self).setUp()
     self.httpd = TestServer()
     self.httpd.start()
     self.http = QHttp("127.0.0.1" , self.httpd.port())
     self.called = False
コード例 #12
0
ファイル: accessManager_test.py プロジェクト: Hasimir/PySide
 def setUp(self):
     super(AccessManagerCase, self).setUp()
     self.httpd = TestServer()
     self.httpd.start()
     self.called = False