OLD | NEW |
| (Empty) |
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories. | |
2 # See LICENSE for details. | |
3 | |
4 # | |
5 from twisted.application import strports | |
6 from twisted.trial import unittest | |
7 | |
8 class ParserTestCase(unittest.TestCase): | |
9 | |
10 f = "Factory" | |
11 | |
12 def testSimpleNumeric(self): | |
13 self.assertEqual(strports.parse('80', self.f), | |
14 ('TCP', (80, self.f), {'interface':'', 'backlog':50})) | |
15 | |
16 def testSimpleTCP(self): | |
17 self.assertEqual(strports.parse('tcp:80', self.f), | |
18 ('TCP', (80, self.f), {'interface':'', 'backlog':50})) | |
19 | |
20 def testInterfaceTCP(self): | |
21 self.assertEqual(strports.parse('tcp:80:interface=127.0.0.1', self.f), | |
22 ('TCP', (80, self.f), | |
23 {'interface':'127.0.0.1', 'backlog':50})) | |
24 | |
25 def testBacklogTCP(self): | |
26 self.assertEqual(strports.parse('tcp:80:backlog=6', self.f), | |
27 ('TCP', (80, self.f), | |
28 {'interface':'', 'backlog':6})) | |
29 | |
30 def testSimpleUnix(self): | |
31 self.assertEqual(strports.parse('unix:/var/run/finger', self.f), | |
32 ('UNIX', ('/var/run/finger', self.f), | |
33 {'mode':0666, 'backlog':50})) | |
34 | |
35 def testModedUNIX(self): | |
36 self.assertEqual(strports.parse('unix:/var/run/finger:mode=0660', | |
37 self.f), | |
38 ('UNIX', ('/var/run/finger', self.f), | |
39 {'mode':0660, 'backlog':50})) | |
40 | |
41 def testAllKeywords(self): | |
42 self.assertEqual(strports.parse('port=80', self.f), | |
43 ('TCP', (80, self.f), {'interface':'', 'backlog':50})) | |
44 | |
45 def testEscape(self): | |
46 self.assertEqual(strports.parse(r'unix:foo\:bar\=baz\:qux\\', self.f), | |
47 ('UNIX', ('foo:bar=baz:qux\\', self.f), | |
48 {'mode':0666, 'backlog':50})) | |
49 | |
50 def testImpliedEscape(self): | |
51 self.assertEqual(strports.parse(r'unix:address=foo=bar', self.f), | |
52 ('UNIX', ('foo=bar', self.f), | |
53 {'mode':0666, 'backlog':50})) | |
54 | |
55 def testNonstandardDefault(self): | |
56 self.assertEqual(strports.parse('filename', self.f, 'unix'), | |
57 ('UNIX', ('filename', self.f), | |
58 {'mode':0666, 'backlog':50})) | |
OLD | NEW |