main
Last change
on this file was
42bd667,
checked in by David Fuertes <dfuertes@…>, 4 years ago
|
Historial Limpio
|
-
Property mode set to
100755
|
File size:
1.0 KB
|
Line | |
---|
1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | |
---|
4 | """Unit tests for http.py """ |
---|
5 | |
---|
6 | import unittest |
---|
7 | |
---|
8 | from gluon.http import HTTP, defined_status |
---|
9 | |
---|
10 | |
---|
11 | class TestHTTP(unittest.TestCase): |
---|
12 | """ Tests http.HTTP """ |
---|
13 | |
---|
14 | def test_status_message(self): |
---|
15 | """ Tests http status code message """ |
---|
16 | |
---|
17 | h = HTTP |
---|
18 | |
---|
19 | def gen_status_str(code, message): |
---|
20 | return str(code) + ' ' + str(message) |
---|
21 | message = '1423 This is a custom message' |
---|
22 | code = 1423 |
---|
23 | self.assertEqual(str(h(gen_status_str(code, message))), |
---|
24 | gen_status_str(code, message)) |
---|
25 | |
---|
26 | # test predefined codes |
---|
27 | for code in defined_status.keys(): |
---|
28 | self.assertEqual( |
---|
29 | str(h(code)), |
---|
30 | gen_status_str(code, defined_status[code])) |
---|
31 | |
---|
32 | # test correct use of status_message |
---|
33 | for code in defined_status.keys(): |
---|
34 | self.assertEqual(str(h(gen_status_str(code, message))), |
---|
35 | gen_status_str(code, message)) |
---|
36 | |
---|
37 | # test wrong call detection |
---|
Note: See
TracBrowser
for help on using the repository browser.