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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
from twisted.trial import unittest
from txdbus import error, marshal
class InterfaceNameValidationTester(unittest.TestCase):
def t(self, s):
self.assertRaises(
error.MarshallingError,
marshal.validateInterfaceName,
s,
)
def test_1(self):
self.t('oops')
def test_2(self):
self.t('foo..bar')
def test_3(self):
self.t('.'.join(['a' + str(i) for i in range(0, 200)]))
def test_4(self):
self.t('.foo.bar')
def test_5(self):
self.t('1foo.bar')
def test_6(self):
self.t('foo.bar!')
def test_7(self):
self.t('foo.2bar')
class ObjectNameValidationTester (InterfaceNameValidationTester):
def t(self, s):
self.assertRaises(
error.MarshallingError,
marshal.validateObjectPath,
s,
)
def test_1(self):
self.t('foo')
def test_2(self):
self.t('/foo/')
def test_3(self):
self.t('/foo//bar')
def test_4(self):
self.t('/foo~bar')
def test_5(self):
self.assertEqual(marshal.validateObjectPath('/foo/bar'), None)
class ErrorNameValidationTester (InterfaceNameValidationTester):
def t(self, s):
self.assertRaises(
error.MarshallingError,
marshal.validateErrorName,
s,
)
class BusNameValidationTester(unittest.TestCase):
def t(self, s):
self.assertRaises(
error.MarshallingError,
marshal.validateBusName,
s,
)
def test_1(self):
self.t('oops')
def test_2(self):
self.t('foo..bar')
def test_3(self):
self.t('.'.join(['a' + str(i) for i in range(0, 200)]))
def test_4(self):
self.t('.foo.bar')
def test_5(self):
self.t('1foo.bar')
def test_6(self):
self.t('foo.bar!')
def test_7(self):
self.t('foo.2bar')
class MemberNameValidationTester(unittest.TestCase):
def t(self, s):
self.assertRaises(
error.MarshallingError,
marshal.validateMemberName,
s,
)
def test_1(self):
self.t('')
def test_2(self):
self.t('f' * 256)
def test_3(self):
self.t('1oops')
def test_4(self):
self.t('foo.bar')
|