aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtNetwork/http_test.py
blob: 5d40405a9d1e0b7805d42aa987c553e39b78acc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

'''Test cases for QHttp'''

import unittest

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.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
        # @bug 114
        QObject.connect(self.http, SIGNAL('requestStarted(int)'), self.callback)
        self.http.get(self.url.path())

        self.app.exec_()
        self.assert_(self.called)

if __name__ == '__main__':
    unittest.main()