Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/stats/test/common.py

Issue 5843385483001856: Stats processing: don`t create file names that are too long (Closed)
Patch Set: Decreased length limit Created Dec. 27, 2013, 7:50 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« sitescripts/stats/common.py ('K') | « sitescripts/stats/common.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 13 matching lines...) Expand all
24 maxDiff = None 24 maxDiff = None
25 25
26 def test_fileencoding(self): 26 def test_fileencoding(self):
27 tests = [ 27 tests = [
28 ("foo_bar", True), 28 ("foo_bar", True),
29 ("1234.txt", True), 29 ("1234.txt", True),
30 ("xYz.DAT", True), 30 ("xYz.DAT", True),
31 ("foo/bar.txt", False), 31 ("foo/bar.txt", False),
32 ("foo/bar+bas-xyz.txt", False), 32 ("foo/bar+bas-xyz.txt", False),
33 (u"foo\u1234-bar\u4321", False), 33 (u"foo\u1234-bar\u4321", False),
34 ("foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfo obarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoob arfoobar", u"foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarf oobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoobarfoo bar\u2026")
34 ] 35 ]
35 for name, expect_identical in tests: 36 for name, expect_identical in tests:
36 path = common.filename_encode(name) 37 path = common.filename_encode(name)
37 if expect_identical: 38 if expect_identical == True:
38 self.assertEqual(path, name, "Encoding '%s' shouldn't change string" % n ame) 39 self.assertEqual(path, name, "Encoding '%s' shouldn't change string" % n ame)
39 else: 40 else:
40 self.assertTrue(re.match(r"^[\w\.\-]*$", path), "Encoding '%s' should re place all special characters" % name) 41 self.assertTrue(re.match(r"^[\w\.\-]*$", path), "Encoding '%s' should re place all special characters" % name)
41 self.assertEqual(common.filename_decode(path), name, "Encoding and decodin g '%s' should produce the original string" % name) 42
43 if isinstance(expect_identical, basestring):
44 self.assertEqual(common.filename_decode(path), expect_identical, "Encodi ng and decoding '%s' should produce a truncated string as result" % name)
45 else:
46 self.assertEqual(common.filename_decode(path), name, "Encoding and decod ing '%s' should produce the original string" % name)
42 47
43 if __name__ == '__main__': 48 if __name__ == '__main__':
44 unittest.main() 49 unittest.main()
OLDNEW
« sitescripts/stats/common.py ('K') | « sitescripts/stats/common.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld