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

Delta Between Two Patch Sets: sitescripts/stats/test/logprocessor.py

Issue 4635035198029824: Issue 1390 - Record referrer for download stats (Closed)
Left Patch Set: Created Sept. 17, 2014, 8:47 p.m.
Right Patch Set: Removed Unicode hack Created Sept. 22, 2014, 10:38 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/stats/common.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 "platform": "chromium", 605 "platform": "chromium",
606 "platformVersion": "28.0", 606 "platformVersion": "28.0",
607 "fullPlatform": "chromium 28.0", 607 "fullPlatform": "chromium 28.0",
608 "downloadInterval": "1 day(s)", 608 "downloadInterval": "1 day(s)",
609 "previousDownload": "2 day(s)", 609 "previousDownload": "2 day(s)",
610 "firstInDay": True, 610 "firstInDay": True,
611 } 611 }
612 ), 612 ),
613 ] 613 ]
614 for line, expected_record in tests: 614 for line, expected_record in tests:
615 result = logprocessor.parse_record(line, set(), FakeGeo(), FakeGeo()) 615 self.assertEqual(logprocessor.parse_record(line, set(), FakeGeo(), FakeGeo ()), expected_record, "Parsing log line '%s'" % line)
616 # assertEqual() treats identical Unicode and non-Unicode strings as
617 # different, make sure that all our strings are non-Unicode.
Sebastian Noack 2014/09/18 15:50:04 Why don't you just use unicode literals above?
Wladimir Palant 2014/09/18 18:42:50 Because I don't know which one will use Unicode -
Sebastian Noack 2014/09/19 09:48:42 According to my tests it doesn't. All strings in t
Wladimir Palant 2014/09/22 10:39:05 For some reason I cannot reproduce it any longer,
618 if result:
619 for key, value in result.iteritems():
620 if isinstance(value, unicode):
621 result[key] = str(value)
622 self.assertEqual(result, expected_record, "Parsing log line '%s'" % line)
623 616
624 def test_record_adding(self): 617 def test_record_adding(self):
625 tests = [ 618 tests = [
626 ( 619 (
627 {"size": 200}, 620 {"size": 200},
628 {}, 621 {},
629 (), 622 (),
630 {"hits": 1, "bandwidth": 200}, 623 {"hits": 1, "bandwidth": 200},
631 ), 624 ),
632 ( 625 (
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 "addonName": {"bar": {"hits": 1, "bandwidth": 200}} 666 "addonName": {"bar": {"hits": 1, "bandwidth": 200}}
674 }, 667 },
675 ), 668 ),
676 ] 669 ]
677 for info, section, ignored_fields, expected_result in tests: 670 for info, section, ignored_fields, expected_result in tests:
678 logprocessor.add_record(info, section, ignored_fields) 671 logprocessor.add_record(info, section, ignored_fields)
679 self.assertEqual(section, expected_result) 672 self.assertEqual(section, expected_result)
680 673
681 if __name__ == '__main__': 674 if __name__ == '__main__':
682 unittest.main() 675 unittest.main()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld