summaryrefslogtreecommitdiffstats
path: root/tests/QtNetwork/http_test.py
blob: b6bfea5ff73b4e7600ff8a95cedb72dd08983478 (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
43
44
45
46
47
'''Test cases for QHttp'''

import unittest

from PySide.QtCore import *
from PySide.QtNetwork import *

from helper import UsesQCoreApplication
from httpd import TestServer

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)

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