~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to testing/mozbase/mozhttpd/tests/requestlog.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This Source Code Form is subject to the terms of the Mozilla Public
2
 
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
 
# You can obtain one at http://mozilla.org/MPL/2.0/.
4
 
 
5
 
import mozhttpd
6
 
import urllib2
7
 
import os
8
 
import unittest
9
 
import time
10
 
 
11
 
here = os.path.dirname(os.path.abspath(__file__))
12
 
 
13
 
class RequestLogTest(unittest.TestCase):
14
 
 
15
 
    def check_logging(self, log_requests=False):
16
 
        filelist = os.listdir(here)
17
 
 
18
 
        httpd = mozhttpd.MozHttpd(port=0, docroot=here, log_requests=log_requests)
19
 
        httpd.start(block=False)
20
 
        url = "http://%s:%s/" % ('127.0.0.1', httpd.httpd.server_port)
21
 
        f = urllib2.urlopen(url)
22
 
        data = f.read()
23
 
 
24
 
        return httpd.request_log
25
 
 
26
 
    def test_logging_enabled(self):
27
 
        request_log = self.check_logging(log_requests=True)
28
 
 
29
 
        self.assertEqual(len(request_log), 1)
30
 
 
31
 
        log_entry = request_log[0]
32
 
        self.assertEqual(log_entry['method'], 'GET')
33
 
        self.assertEqual(log_entry['path'], '/')
34
 
        self.assertEqual(type(log_entry['time']), float)
35
 
 
36
 
    def test_logging_disabled(self):
37
 
        request_log = self.check_logging(log_requests=False)
38
 
 
39
 
        self.assertEqual(len(request_log), 0)
40
 
 
41
 
if __name__ == '__main__':
42
 
    unittest.main()