| 1 | # -*- mode: python; coding: utf-8 -*- |
|---|
| 2 | # :Progetto: vcpx -- svn specific tests |
|---|
| 3 | # :Creato: gio 11 nov 2004 19:09:06 CET |
|---|
| 4 | # :Autore: Lele Gaifax <lele@nautilus.homeip.net> |
|---|
| 5 | # :Licenza: GNU General Public License |
|---|
| 6 | # |
|---|
| 7 | |
|---|
| 8 | from unittest import TestCase, TestSuite |
|---|
| 9 | from datetime import datetime |
|---|
| 10 | from StringIO import StringIO |
|---|
| 11 | from vcpx.svn import changesets_from_svnlog |
|---|
| 12 | |
|---|
| 13 | class SvnLogParserTest(TestCase): |
|---|
| 14 | """Ensure the svn log parser does its job.""" |
|---|
| 15 | |
|---|
| 16 | SIMPLE_RENAME_TEST = """\ |
|---|
| 17 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 18 | <log> |
|---|
| 19 | <logentry |
|---|
| 20 | revision="2"> |
|---|
| 21 | <author>lele</author> |
|---|
| 22 | <date>2004-11-12T15:05:37.134366Z</date> |
|---|
| 23 | <paths> |
|---|
| 24 | <path |
|---|
| 25 | action="A">/trunk/dir</path> |
|---|
| 26 | <path |
|---|
| 27 | action="A">/trunk/dir/a.txt</path> |
|---|
| 28 | </paths> |
|---|
| 29 | <msg>create tree</msg> |
|---|
| 30 | </logentry> |
|---|
| 31 | <logentry |
|---|
| 32 | revision="3"> |
|---|
| 33 | <author>lele</author> |
|---|
| 34 | <date>2004-11-12T15:06:04.193650Z</date> |
|---|
| 35 | <paths> |
|---|
| 36 | <path |
|---|
| 37 | action="D">/trunk/dir</path> |
|---|
| 38 | <path |
|---|
| 39 | copyfrom-path="/trunk/dir" |
|---|
| 40 | copyfrom-rev="1" |
|---|
| 41 | action="A">/trunk/new</path> |
|---|
| 42 | </paths> |
|---|
| 43 | <msg>rename dir</msg> |
|---|
| 44 | </logentry> |
|---|
| 45 | </log> |
|---|
| 46 | """ |
|---|
| 47 | |
|---|
| 48 | def testRenameBehaviour(self): |
|---|
| 49 | """Verify svn log parser behaves correctly on renames""" |
|---|
| 50 | |
|---|
| 51 | log = StringIO(self.SIMPLE_RENAME_TEST) |
|---|
| 52 | csets = changesets_from_svnlog(log, |
|---|
| 53 | 'file:///tmp/t/repo', |
|---|
| 54 | '/trunk') |
|---|
| 55 | self.assertEqual(len(csets), 2) |
|---|
| 56 | |
|---|
| 57 | cset = csets[0] |
|---|
| 58 | self.assertEqual(cset.author, 'lele') |
|---|
| 59 | self.assertEqual(cset.date, datetime(2004,11,12,15,05,37,134366)) |
|---|
| 60 | self.assertEqual(cset.log, 'create tree') |
|---|
| 61 | self.assertEqual(len(cset.entries), 2) |
|---|
| 62 | |
|---|
| 63 | entry = cset.entries[0] |
|---|
| 64 | self.assertEqual(entry.name, 'dir') |
|---|
| 65 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 66 | |
|---|
| 67 | entry = cset.entries[1] |
|---|
| 68 | self.assertEqual(entry.name, 'dir/a.txt') |
|---|
| 69 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 70 | |
|---|
| 71 | cset = csets[1] |
|---|
| 72 | self.assertEqual(cset.author, 'lele') |
|---|
| 73 | self.assertEqual(cset.date, datetime(2004,11,12,15,06,04,193650)) |
|---|
| 74 | self.assertEqual(cset.log, 'rename dir') |
|---|
| 75 | self.assertEqual(len(cset.entries), 1) |
|---|
| 76 | |
|---|
| 77 | entry = cset.entries[0] |
|---|
| 78 | self.assertEqual(entry.name, 'new') |
|---|
| 79 | self.assertEqual(entry.action_kind, entry.RENAMED) |
|---|
| 80 | self.assertEqual(entry.old_name, 'dir') |
|---|
| 81 | |
|---|
| 82 | RENAME_OUT_TEST = """\ |
|---|
| 83 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 84 | <log> |
|---|
| 85 | <logentry |
|---|
| 86 | revision="894"> |
|---|
| 87 | <author>anthony</author> |
|---|
| 88 | <date>2004-11-09T06:54:20.709243Z</date> |
|---|
| 89 | <paths> |
|---|
| 90 | <path |
|---|
| 91 | action="D">/trunk/shtoom/tmp</path> |
|---|
| 92 | <path |
|---|
| 93 | copyfrom-path="/trunk/shtoom/tmp" |
|---|
| 94 | copyfrom-rev="893" |
|---|
| 95 | action="A">/sandbox</path> |
|---|
| 96 | </paths> |
|---|
| 97 | <msg>Moving to a /sandbox |
|---|
| 98 | </msg> |
|---|
| 99 | </logentry> |
|---|
| 100 | </log> |
|---|
| 101 | """ |
|---|
| 102 | |
|---|
| 103 | def testRenameOutBehaviour(self): |
|---|
| 104 | """Verify svn log parser behaves correctly on renames outside tracked tree""" |
|---|
| 105 | |
|---|
| 106 | log = StringIO(self.RENAME_OUT_TEST) |
|---|
| 107 | csets = changesets_from_svnlog(log, |
|---|
| 108 | 'http://server/svn/Shtoom', |
|---|
| 109 | '/trunk') |
|---|
| 110 | self.assertEqual(len(csets), 1) |
|---|
| 111 | |
|---|
| 112 | cset = csets[0] |
|---|
| 113 | self.assertEqual(cset.author, 'anthony') |
|---|
| 114 | self.assertEqual(cset.date, datetime(2004,11,9,6,54,20,709243)) |
|---|
| 115 | self.assertEqual(cset.log, 'Moving to a /sandbox') |
|---|
| 116 | self.assertEqual(len(cset.entries), 1) |
|---|
| 117 | |
|---|
| 118 | entry = cset.entries[0] |
|---|
| 119 | self.assertEqual(entry.name, 'shtoom/tmp') |
|---|
| 120 | self.assertEqual(entry.action_kind, entry.DELETED) |
|---|
| 121 | |
|---|
| 122 | COPY_AND_RENAME_TEST = """\ |
|---|
| 123 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 124 | <log> |
|---|
| 125 | <logentry |
|---|
| 126 | revision="1"> |
|---|
| 127 | <author>lele</author> |
|---|
| 128 | <date>2005-01-08T17:36:39.131126Z</date> |
|---|
| 129 | <paths> |
|---|
| 130 | <path |
|---|
| 131 | action="A">/test/file1.txt</path> |
|---|
| 132 | </paths> |
|---|
| 133 | <msg>First commit</msg> |
|---|
| 134 | </logentry> |
|---|
| 135 | <logentry |
|---|
| 136 | revision="2"> |
|---|
| 137 | <author>lele</author> |
|---|
| 138 | <date>2005-01-08T17:36:55.174757Z</date> |
|---|
| 139 | <paths> |
|---|
| 140 | <path |
|---|
| 141 | copyfrom-path="/test/file1.txt" |
|---|
| 142 | copyfrom-rev="1" |
|---|
| 143 | action="A">/test/file2.txt</path> |
|---|
| 144 | </paths> |
|---|
| 145 | <msg>Copy</msg> |
|---|
| 146 | </logentry> |
|---|
| 147 | <logentry |
|---|
| 148 | revision="3"> |
|---|
| 149 | <author>lele</author> |
|---|
| 150 | <date>2005-01-08T17:42:41.347315Z</date> |
|---|
| 151 | <paths> |
|---|
| 152 | <path |
|---|
| 153 | action="D">/test/file1.txt</path> |
|---|
| 154 | </paths> |
|---|
| 155 | <msg>Remove</msg> |
|---|
| 156 | </logentry> |
|---|
| 157 | <logentry |
|---|
| 158 | revision="4"> |
|---|
| 159 | <author>lele</author> |
|---|
| 160 | <date>2005-01-08T17:43:09.909127Z</date> |
|---|
| 161 | <paths> |
|---|
| 162 | <path |
|---|
| 163 | copyfrom-path="/test/file2.txt" |
|---|
| 164 | copyfrom-rev="2" |
|---|
| 165 | action="A">/test/file1.txt</path> |
|---|
| 166 | <path |
|---|
| 167 | action="D">/test/file2.txt</path> |
|---|
| 168 | </paths> |
|---|
| 169 | <msg>Move</msg> |
|---|
| 170 | </logentry> |
|---|
| 171 | </log> |
|---|
| 172 | """ |
|---|
| 173 | |
|---|
| 174 | def testCopyAndRename(self): |
|---|
| 175 | """Verify svn log parser behaves correctly on copies""" |
|---|
| 176 | |
|---|
| 177 | log = StringIO(self.COPY_AND_RENAME_TEST) |
|---|
| 178 | csets = changesets_from_svnlog(log, |
|---|
| 179 | 'file:///tmp/rep', |
|---|
| 180 | '/test') |
|---|
| 181 | self.assertEqual(len(csets), 4) |
|---|
| 182 | |
|---|
| 183 | cset = csets[1] |
|---|
| 184 | self.assertEqual(cset.author, 'lele') |
|---|
| 185 | self.assertEqual(cset.date, datetime(2005,1,8, 17,36,55,174757)) |
|---|
| 186 | self.assertEqual(cset.log, 'Copy') |
|---|
| 187 | self.assertEqual(len(cset.entries), 1) |
|---|
| 188 | |
|---|
| 189 | entry = cset.entries[0] |
|---|
| 190 | self.assertEqual(entry.name, 'file2.txt') |
|---|
| 191 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 192 | self.assertEqual(entry.old_name, 'file1.txt') |
|---|
| 193 | |
|---|
| 194 | cset = csets[2] |
|---|
| 195 | self.assertEqual(cset.date, datetime(2005,1,8, 17,42,41,347315)) |
|---|
| 196 | self.assertEqual(cset.log, 'Remove') |
|---|
| 197 | self.assertEqual(len(cset.entries), 1) |
|---|
| 198 | |
|---|
| 199 | entry = cset.entries[0] |
|---|
| 200 | self.assertEqual(entry.name, 'file1.txt') |
|---|
| 201 | self.assertEqual(entry.action_kind, entry.DELETED) |
|---|
| 202 | |
|---|
| 203 | cset = csets[3] |
|---|
| 204 | self.assertEqual(cset.date, datetime(2005,1,8, 17,43,9,909127)) |
|---|
| 205 | self.assertEqual(cset.log, 'Move') |
|---|
| 206 | self.assertEqual(len(cset.entries), 1) |
|---|
| 207 | |
|---|
| 208 | entry = cset.entries[0] |
|---|
| 209 | self.assertEqual(entry.name, 'file1.txt') |
|---|
| 210 | self.assertEqual(entry.action_kind, entry.RENAMED) |
|---|
| 211 | self.assertEqual(entry.old_name, 'file2.txt') |
|---|
| 212 | |
|---|
| 213 | SVN_R_EVENT_TEST = """\ |
|---|
| 214 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 215 | <log> |
|---|
| 216 | <logentry |
|---|
| 217 | revision="1378"> |
|---|
| 218 | <author>cmlenz</author> |
|---|
| 219 | <date>2005-03-21T08:06:13.381116Z</date> |
|---|
| 220 | <paths> |
|---|
| 221 | <path |
|---|
| 222 | action="M">/trunk/trac/db.py</path> |
|---|
| 223 | </paths> |
|---|
| 224 | <msg>Fix to the database connection wrapper in {{{trac/db.py}}}, which would cause infinite recursion when initialization failed. Closes #1327. Thanks to Mark Rowe for the patch.</msg> |
|---|
| 225 | </logentry> |
|---|
| 226 | <logentry |
|---|
| 227 | revision="1379"> |
|---|
| 228 | <author>cmlenz</author> |
|---|
| 229 | <date>2005-03-21T08:34:02.522947Z</date> |
|---|
| 230 | <paths> |
|---|
| 231 | <path |
|---|
| 232 | copyfrom-path="/trunk/scripts/trac-admin" |
|---|
| 233 | copyfrom-rev="1377" |
|---|
| 234 | action="A">/trunk/trac/scripts/admin.py</path> |
|---|
| 235 | <path |
|---|
| 236 | action="A">/trunk/trac/scripts</path> |
|---|
| 237 | <path |
|---|
| 238 | action="M">/trunk/trac/tests/tracadmin.py</path> |
|---|
| 239 | <path |
|---|
| 240 | action="R">/trunk/scripts/trac-admin</path> |
|---|
| 241 | <path |
|---|
| 242 | action="A">/trunk/trac/scripts/__init__.py</path> |
|---|
| 243 | <path |
|---|
| 244 | action="M">/trunk/trac/tests/environment.py</path> |
|---|
| 245 | <path |
|---|
| 246 | action="M">/trunk/setup.py</path> |
|---|
| 247 | </paths> |
|---|
| 248 | <msg>Applied Mark Rowe's patch for refactoring trad-admin into a real module so that the unit tests don't need to invoke it through the shell. Closes #1328. Many thanks.</msg> |
|---|
| 249 | </logentry> |
|---|
| 250 | </log> |
|---|
| 251 | """ |
|---|
| 252 | |
|---|
| 253 | def testREvent(self): |
|---|
| 254 | """Verify how tailor handle svn "R" event""" |
|---|
| 255 | |
|---|
| 256 | log = StringIO(self.SVN_R_EVENT_TEST) |
|---|
| 257 | csets = changesets_from_svnlog(log, |
|---|
| 258 | 'file:///tmp/rep', |
|---|
| 259 | '/trunk') |
|---|
| 260 | self.assertEqual(len(csets), 2) |
|---|
| 261 | |
|---|
| 262 | cset = csets[1] |
|---|
| 263 | self.assertEqual(cset.author, 'cmlenz') |
|---|
| 264 | self.assertEqual(cset.date, datetime(2005,3,21, 8,34,02,522947)) |
|---|
| 265 | self.assertEqual(len(cset.entries), 7) |
|---|
| 266 | |
|---|
| 267 | entry = cset.entries[0] |
|---|
| 268 | self.assertEqual(entry.name, 'scripts/trac-admin') |
|---|
| 269 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 270 | |
|---|
| 271 | entry = cset.entries[1] |
|---|
| 272 | self.assertEqual(entry.name, 'setup.py') |
|---|
| 273 | self.assertEqual(entry.action_kind, entry.UPDATED) |
|---|
| 274 | |
|---|
| 275 | entry = cset.entries[2] |
|---|
| 276 | self.assertEqual(entry.name, 'trac/scripts') |
|---|
| 277 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 278 | |
|---|
| 279 | entry = cset.entries[3] |
|---|
| 280 | self.assertEqual(entry.name, 'trac/scripts/__init__.py') |
|---|
| 281 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 282 | |
|---|
| 283 | entry = cset.entries[4] |
|---|
| 284 | self.assertEqual(entry.name, 'trac/scripts/admin.py') |
|---|
| 285 | self.assertEqual(entry.action_kind, entry.RENAMED) |
|---|
| 286 | self.assertEqual(entry.old_name, 'scripts/trac-admin') |
|---|
| 287 | |
|---|
| 288 | entry = cset.entries[5] |
|---|
| 289 | self.assertEqual(entry.name, 'trac/tests/environment.py') |
|---|
| 290 | self.assertEqual(entry.action_kind, entry.UPDATED) |
|---|
| 291 | |
|---|
| 292 | SVN_REPOS_ROOT_TEST = """\ |
|---|
| 293 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 294 | <log> |
|---|
| 295 | <logentry |
|---|
| 296 | revision="2"> |
|---|
| 297 | <author>lele</author> |
|---|
| 298 | <date>2005-04-14T20:32:24.686518Z</date> |
|---|
| 299 | <paths> |
|---|
| 300 | <path |
|---|
| 301 | action="A">/trunk/a.txt</path> |
|---|
| 302 | <path |
|---|
| 303 | action="A">/trunk/b.txt</path> |
|---|
| 304 | </paths> |
|---|
| 305 | <msg>Some files in trunk</msg> |
|---|
| 306 | </logentry> |
|---|
| 307 | <logentry |
|---|
| 308 | revision="3"> |
|---|
| 309 | <author>lele</author> |
|---|
| 310 | <date>2005-04-14T20:32:55.602712Z</date> |
|---|
| 311 | <paths> |
|---|
| 312 | <path |
|---|
| 313 | copyfrom-path="/trunk" |
|---|
| 314 | copyfrom-rev="1" |
|---|
| 315 | action="A">/branches/branch-a</path> |
|---|
| 316 | <path |
|---|
| 317 | copyfrom-path="/trunk/a.txt" |
|---|
| 318 | copyfrom-rev="2" |
|---|
| 319 | action="A">/branches/branch-a/a.txt</path> |
|---|
| 320 | <path |
|---|
| 321 | copyfrom-path="/trunk/b.txt" |
|---|
| 322 | copyfrom-rev="2" |
|---|
| 323 | action="A">/branches/branch-a/b.txt</path> |
|---|
| 324 | </paths> |
|---|
| 325 | <msg>Branched A</msg> |
|---|
| 326 | </logentry> |
|---|
| 327 | <logentry |
|---|
| 328 | revision="4"> |
|---|
| 329 | <author>lele</author> |
|---|
| 330 | <date>2005-04-14T20:34:25.374254Z</date> |
|---|
| 331 | <paths> |
|---|
| 332 | <path |
|---|
| 333 | action="M">/branches/branch-a/a.txt</path> |
|---|
| 334 | <path |
|---|
| 335 | action="M">/branches/branch-a/b.txt</path> |
|---|
| 336 | </paths> |
|---|
| 337 | <msg>Capitalization</msg> |
|---|
| 338 | </logentry> |
|---|
| 339 | <logentry |
|---|
| 340 | revision="5"> |
|---|
| 341 | <author>lele</author> |
|---|
| 342 | <date>2005-04-14T20:35:44.753550Z</date> |
|---|
| 343 | <paths> |
|---|
| 344 | <path |
|---|
| 345 | action="M">/trunk/a.txt</path> |
|---|
| 346 | <path |
|---|
| 347 | action="M">/trunk/b.txt</path> |
|---|
| 348 | </paths> |
|---|
| 349 | <msg>Merged back</msg> |
|---|
| 350 | </logentry> |
|---|
| 351 | </log> |
|---|
| 352 | """ |
|---|
| 353 | |
|---|
| 354 | def testTrackingRoot(self): |
|---|
| 355 | """Verify we are able to track the root of the repository""" |
|---|
| 356 | |
|---|
| 357 | log = StringIO(self.SVN_REPOS_ROOT_TEST) |
|---|
| 358 | csets = changesets_from_svnlog(log, |
|---|
| 359 | 'svn+ssh://caia/tmp/svn', |
|---|
| 360 | '/') |
|---|
| 361 | self.assertEqual(len(csets), 4) |
|---|
| 362 | |
|---|
| 363 | cset = csets[1] |
|---|
| 364 | self.assertEqual(len(cset.entries), 3) |
|---|
| 365 | |
|---|
| 366 | entry = cset.entries[0] |
|---|
| 367 | self.assertEqual(entry.name, 'branches/branch-a') |
|---|
| 368 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 369 | |
|---|
| 370 | entry = cset.entries[1] |
|---|
| 371 | self.assertEqual(entry.name, 'branches/branch-a/a.txt') |
|---|
| 372 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 373 | |
|---|
| 374 | entry = cset.entries[2] |
|---|
| 375 | self.assertEqual(entry.name, 'branches/branch-a/b.txt') |
|---|
| 376 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 377 | |
|---|
| 378 | PYDIST_STRANGE_CASE = """\ |
|---|
| 379 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 380 | <log> |
|---|
| 381 | <logentry |
|---|
| 382 | revision="7969"> |
|---|
| 383 | <author>hpk</author> |
|---|
| 384 | <date>2004-12-22T10:30:39.458701Z</date> |
|---|
| 385 | <paths> |
|---|
| 386 | <path |
|---|
| 387 | copyfrom-path="/py/dist/example/test" |
|---|
| 388 | copyfrom-rev="7968" |
|---|
| 389 | action="R">/py/dist/py/documentation/example/test</path> |
|---|
| 390 | <path |
|---|
| 391 | action="D">/py/dist/example</path> |
|---|
| 392 | <path |
|---|
| 393 | copyfrom-path="/py/dist/example" |
|---|
| 394 | copyfrom-rev="7965" |
|---|
| 395 | action="A">/py/dist/py/documentation/example</path> |
|---|
| 396 | <path |
|---|
| 397 | action="M">/py/dist/py/documentation/test.txt</path> |
|---|
| 398 | </paths> |
|---|
| 399 | <msg>moved example directory below the documentation directory lib |
|---|
| 400 | |
|---|
| 401 | </msg> |
|---|
| 402 | </logentry> |
|---|
| 403 | </log> |
|---|
| 404 | """ |
|---|
| 405 | def testPydistStrangeCase(self): |
|---|
| 406 | """Verify we are able to groke with svn 'R' strangeness""" |
|---|
| 407 | |
|---|
| 408 | log = StringIO(self.PYDIST_STRANGE_CASE) |
|---|
| 409 | csets = changesets_from_svnlog(log, |
|---|
| 410 | 'http://codespeak.net/svn', |
|---|
| 411 | '/py/dist') |
|---|
| 412 | |
|---|
| 413 | self.assertEqual(len(csets), 1) |
|---|
| 414 | |
|---|
| 415 | cset = csets[0] |
|---|
| 416 | self.assertEqual(len(cset.entries), 3) |
|---|
| 417 | |
|---|
| 418 | entry = cset.entries[0] |
|---|
| 419 | self.assertEqual(entry.name, 'py/documentation/example') |
|---|
| 420 | self.assertEqual(entry.action_kind, entry.RENAMED) |
|---|
| 421 | self.assertEqual(entry.old_name, 'example') |
|---|
| 422 | |
|---|
| 423 | entry = cset.entries[1] |
|---|
| 424 | self.assertEqual(entry.name, 'py/documentation/example/test') |
|---|
| 425 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 426 | |
|---|
| 427 | entry = cset.entries[2] |
|---|
| 428 | self.assertEqual(entry.name, 'py/documentation/test.txt') |
|---|
| 429 | self.assertEqual(entry.action_kind, entry.UPDATED) |
|---|
| 430 | |
|---|
| 431 | log = StringIO(self.PYDIST_STRANGE_CASE) |
|---|
| 432 | csets = changesets_from_svnlog(log, |
|---|
| 433 | 'http://codespeak.net/svn', |
|---|
| 434 | '/py/dist/py') |
|---|
| 435 | |
|---|
| 436 | self.assertEqual(len(csets), 1) |
|---|
| 437 | |
|---|
| 438 | cset = csets[0] |
|---|
| 439 | self.assertEqual(len(cset.entries), 3) |
|---|
| 440 | |
|---|
| 441 | entry = cset.entries[0] |
|---|
| 442 | self.assertEqual(entry.name, 'documentation/example') |
|---|
| 443 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 444 | |
|---|
| 445 | entry = cset.entries[1] |
|---|
| 446 | self.assertEqual(entry.name, 'documentation/example/test') |
|---|
| 447 | self.assertEqual(entry.action_kind, entry.ADDED) |
|---|
| 448 | |
|---|
| 449 | entry = cset.entries[2] |
|---|
| 450 | self.assertEqual(entry.name, 'documentation/test.txt') |
|---|
| 451 | self.assertEqual(entry.action_kind, entry.UPDATED) |
|---|
| 452 | |
|---|
| 453 | ENCODING_TEST = """\ |
|---|
| 454 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 455 | <log> |
|---|
| 456 | <logentry |
|---|
| 457 | revision="7564"> |
|---|
| 458 | <author>fschulze</author> |
|---|
| 459 | <date>2005-07-20T17:47:53.425055Z</date> |
|---|
| 460 | <msg>Fix http://members.plone.org/collector/4034 — Collapsible fieldsets need a full width mode.</msg> |
|---|
| 461 | </logentry> |
|---|
| 462 | </log> |
|---|
| 463 | """ |
|---|
| 464 | def testUnicode(self): |
|---|
| 465 | """Verify svn parser returns unicode strings""" |
|---|
| 466 | |
|---|
| 467 | log = StringIO(self.ENCODING_TEST) |
|---|
| 468 | csets = changesets_from_svnlog(log, |
|---|
| 469 | 'http://svn.plone.org/plone/CMFPlone', |
|---|
| 470 | '/branches/2.1') |
|---|
| 471 | |
|---|
| 472 | self.assertEqual(len(csets), 1) |
|---|
| 473 | |
|---|
| 474 | log = csets[0].log |
|---|
| 475 | self.assertEqual(type(log), type(u'€')) |
|---|
| 476 | self.assertEqual(len(log), 91) |
|---|
| 477 | self.assertRaises(UnicodeEncodeError, log.encode, 'iso-8859-1') |
|---|
| 478 | self.assertEqual(len(log.encode('ascii', 'ignore')), 90) |
|---|