Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
PlacelessTranslationService.tests.testPTS.TestPTS Class Reference

List of all members.

Public Member Functions

def afterSetUp
def tearDown
def testClassVersion
def testInterpolate

Public Attributes

 service
 dir1
 dir2
 mo_file
 mo_file2

Detailed Description

Definition at line 26 of file testPTS.py.


Member Function Documentation

Definition at line 28 of file testPTS.py.

00028 
00029     def afterSetUp(self):
00030         self.service = self.app.Control_Panel.TranslationService
00031         self.dir1 = os.path.join(os.path.dirname(__file__), 'i18nsample')
00032         self.dir2 = os.path.join(os.path.dirname(__file__), 'i18nsample2')
00033         self.mo_file = os.path.join(self.dir1, 'fr', 'LC_MESSAGES', 'plone.mo')
00034         self.mo_file2 = os.path.join(self.dir2, 'fr', 'LC_MESSAGES', 'plone.mo')

Definition at line 35 of file testPTS.py.

00035 
00036     def tearDown(self):
00037         for f in (self.mo_file, self.mo_file2):
00038             if os.path.exists(f):
00039                 os.remove(f)

Definition at line 40 of file testPTS.py.

00040 
00041     def testClassVersion(self):
00042         clv = PTS._class_version
00043         fsv = getFSVersionTuple()
00044         for i in range(3):
00045             self.assertEquals(clv[i], fsv[i],
00046                               'class version (%s) does not match filesystem version (%s)' % (clv, fsv))

Here is the call graph for this function:

Definition at line 47 of file testPTS.py.

00047 
00048     def testInterpolate(self):
00049         # empty mapping
00050         text = 'ascii'
00051         self.assertEquals(self.service.interpolate(text, []), text)
00052 
00053         text = 'ascii-with-funky-chars\xe2'
00054         self.assertEquals(self.service.interpolate(text, []), text)
00055 
00056         text = u'unicode-with-ascii-only'
00057         self.assertEquals(self.service.interpolate(text, []), text)
00058 
00059         text = u'unicode\xe2'
00060         self.assertEquals(self.service.interpolate(text, []), text)
00061 
00062         # text is ascii
00063         text = '${ascii}'
00064         mapping = {u'ascii' : 'ascii'}
00065         expected = 'ascii'
00066         self.assertEquals(self.service.interpolate(text, mapping), expected)
00067 
00068         text = '${ascii}'
00069         mapping = {u'ascii' : 'ascii-with-funky-chars\xe2'}
00070         expected = 'ascii-with-funky-chars\xe2'
00071         self.assertEquals(self.service.interpolate(text, mapping), expected)
00072 
00073         text = '${ascii}'
00074         mapping = {u'ascii' : u'unicode-with-ascii-only'}
00075         expected = u'unicode-with-ascii-only'
00076         self.assertEquals(self.service.interpolate(text, mapping), expected)
00077 
00078         text = '${ascii}'
00079         mapping = {u'ascii' : u'unicode\xe2'}
00080         expected = u'unicode\xe2'
00081         self.assertEquals(self.service.interpolate(text, mapping), expected)
00082 
00083         text = '${ascii}'
00084         mapping = {'ascii' : 1}
00085         expected = '1'
00086         self.assertEquals(self.service.interpolate(text, mapping), expected)
00087 
00088         # text is ascii with funky chars
00089         text = '${ascii-with-funky-chars}\xc2'
00090         mapping = {u'ascii-with-funky-chars' : 'ascii'}
00091         expected = 'ascii\xc2'
00092         self.assertEquals(self.service.interpolate(text, mapping), expected)
00093 
00094         text = '${ascii-with-funky-chars}\xc2'
00095         mapping = {u'ascii-with-funky-chars' : 'ascii-with-funky-chars\xe2'}
00096         expected = 'ascii-with-funky-chars\xe2\xc2'
00097         self.assertEquals(self.service.interpolate(text, mapping), expected)
00098 
00099         text = '${ascii-with-funky-chars}\xc2'
00100         mapping = {u'ascii-with-funky-chars' : u'unicode-with-ascii-only'}
00101         expected = '${ascii-with-funky-chars}\xc2'
00102         self.assertEquals(self.service.interpolate(text, mapping), expected)
00103 
00104         text = '${ascii-with-funky-chars}\xc2'
00105         mapping = {u'ascii-with-funky-chars' : u'unicode\xe2'}
00106         expected = '${ascii-with-funky-chars}\xc2'
00107         self.assertEquals(self.service.interpolate(text, mapping), expected)
00108 
00109         text = '${ascii-with-funky-chars}\xc2'
00110         mapping = {'ascii-with-funky-chars' : 1}
00111         expected = '1\xc2'
00112         self.assertEquals(self.service.interpolate(text, mapping), expected)
00113 
00114         # text is unicode with only ascii chars
00115         text = u'${unicode-with-ascii-only}'
00116         mapping = {u'unicode-with-ascii-only' : 'ascii'}
00117         expected = 'ascii'
00118         self.assertEquals(self.service.interpolate(text, mapping), expected)
00119 
00120         text = u'${unicode-with-ascii-only}'
00121         mapping = {u'unicode-with-ascii-only' : 'ascii-with-funky-chars\xe2'}
00122         expected = u'${unicode-with-ascii-only}'
00123         self.assertEquals(self.service.interpolate(text, mapping), expected)
00124 
00125         text = u'${unicode-with-ascii-only}'
00126         mapping = {u'unicode-with-ascii-only' : u'unicode-with-ascii-only'}
00127         expected = u'unicode-with-ascii-only'
00128         self.assertEquals(self.service.interpolate(text, mapping), expected)
00129 
00130         text = u'${unicode-with-ascii-only}'
00131         mapping = {u'unicode-with-ascii-only' : u'unicode\xe2'}
00132         expected = u'unicode\xe2'
00133         self.assertEquals(self.service.interpolate(text, mapping), expected)
00134 
00135         text = u'${unicode-with-ascii-only}'
00136         mapping = {u'unicode-with-ascii-only' : 1}
00137         expected = u'1'
00138         self.assertEquals(self.service.interpolate(text, mapping), expected)
00139 
00140         # text is real unicode
00141         text = u'${unicode}\xc2'
00142         mapping = {u'unicode' : 'ascii'}
00143         expected = u'ascii\xc2'
00144         self.assertEquals(self.service.interpolate(text, mapping), expected)
00145 
00146         text = u'${unicode}\xc2'
00147         mapping = {u'unicode' : 'ascii-with-funky-chars\xe2'}
00148         expected = u'${unicode}\xc2'
00149         self.assertEquals(self.service.interpolate(text, mapping), expected)
00150 
00151         text = u'${unicode}\xc2'
00152         mapping = {u'unicode' : u'unicode-with-ascii-only'}
00153         expected = u'unicode-with-ascii-only\xc2'
00154         self.assertEquals(self.service.interpolate(text, mapping), expected)
00155 
00156         text = u'${unicode}\xc2'
00157         mapping = {u'unicode' : u'unicode\xe2'}
00158         expected = u'unicode\xe2\xc2'
00159         self.assertEquals(self.service.interpolate(text, mapping), expected)
00160 
00161         text = u'${unicode}\xc2'
00162         mapping = {'unicode' : 1}
00163         expected = u'1\xc2'
00164         self.assertEquals(self.service.interpolate(text, mapping), expected)


Member Data Documentation

Definition at line 30 of file testPTS.py.

Definition at line 31 of file testPTS.py.

Definition at line 32 of file testPTS.py.

Definition at line 33 of file testPTS.py.

Definition at line 29 of file testPTS.py.


The documentation for this class was generated from the following file: