Index: sitescripts/stats/test/logprocessor.py |
=================================================================== |
--- a/sitescripts/stats/test/logprocessor.py |
+++ b/sitescripts/stats/test/logprocessor.py |
@@ -335,16 +335,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "devbuilds/adblockpluschrome/updates.xml", |
"query": "os=mac&arch=x86&nacl_arch=x86-32&prod=chromecrx&prodchannel=stable&prodversion=28.0.1500.71&x=id%3Dldcecbkkoecffmfljeihcmifjjdoepkn%26v%3D1.5.3.977%26uc", |
"size": 867, |
+ "referrer": "-", |
"ua": "Chrome", |
"uaversion": "28.0", |
"fullua": "Chrome 28.0", |
"clientid": "-", |
"addonName": "adblockpluschrome", |
"addonVersion": "1.5.3.977", |
"fullAddon": "adblockpluschrome 1.5.3.977", |
"application": "chrome", |
@@ -372,16 +373,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "devbuilds/abpcustomization/update.rdf", |
"query": "reqVersion=2&id=customization@adblockplus.org&version=1.0.4a.74&maxAppVersion=26.0&status=userEnabled&appID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&appVersion=25.0a1&appOS=WINNT&appABI=x86_64-msvc&locale=en-US¤tAppVersion=25.0a1&updateType=97", |
"size": 867, |
+ "referrer": "-", |
"ua": "Firefox", |
"uaversion": "25.0", |
"fullua": "Firefox 25.0", |
"clientid": "-", |
"addonName": "abpcustomization", |
"addonVersion": "1.0.4a.74", |
"fullAddon": "abpcustomization 1.0.4a.74", |
"application": "firefox", |
@@ -397,16 +399,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "devbuilds/adblockplusie/update.json", |
"query": "addonName=adblockplusie&addonVersion=2.0&application=msie64&applicationVersion=10.0&platform=libadblockplus&platformVersion=1.0&lastVersion=0", |
"size": 867, |
+ "referrer": "-", |
"ua": "ABP", |
"uaversion": "", |
"fullua": "ABP ", |
"clientid": "-", |
"addonName": "adblockplusie", |
"addonVersion": "2.0", |
"fullAddon": "adblockplusie 2.0", |
"application": "msie64", |
@@ -428,16 +431,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "adblockplusandroid-1.1.2.apk", |
"query": "", |
"size": 49152, |
+ "referrer": "https://adblockplus.org/en/android-install", |
"ua": "Mobile Safari", |
"uaversion": "4.0", |
"fullua": "Mobile Safari 4.0", |
"clientid": "-", |
"installType": "install", |
} |
), |
( |
@@ -448,16 +452,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "devbuilds/adblockplus/adblockplus-2.3.2.3712.xpi", |
"query": "update", |
"size": 827261, |
+ "referrer": "-", |
"ua": "Firefox", |
"uaversion": "22.0", |
"fullua": "Firefox 22.0", |
"clientid": None, |
"installType": "update", |
} |
), |
( |
@@ -468,16 +473,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "exceptionrules.txt", |
"query": "addonName=adblockplus&addonVersion=2.3.2&application=firefox&applicationVersion=22.0&platform=gecko&platformVersion=22.0&lastVersion=201307311503", |
"size": 14303, |
+ "referrer": "-", |
"ua": "Firefox", |
"uaversion": "22.0", |
"fullua": "Firefox 22.0", |
"clientid": "-", |
"addonName": "adblockplus", |
"addonVersion": "2.3.2", |
"fullAddon": "adblockplus 2.3.2", |
"application": "firefox", |
@@ -498,16 +504,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "easylist.txt", |
"query": "_=1375446528229", |
"size": 326120, |
+ "referrer": "-", |
"ua": "Chrome", |
"uaversion": "28.0", |
"fullua": "Chrome 28.0", |
"clientid": "AdBlock/2.6.2", |
"addonName": "chromeadblock", |
"addonVersion": "2.6.2", |
"fullAddon": "chromeadblock 2.6.2", |
"application": "unknown", |
@@ -528,16 +535,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "easylistitaly.txt", |
"query": "", |
"size": 85879, |
+ "referrer": "-", |
"ua": "Other", |
"uaversion": "", |
"fullua": "Other ", |
"clientid": "-", |
"addonName": "unknown", |
"addonVersion": "unknown", |
"fullAddon": "unknown unknown", |
"application": "unknown", |
@@ -558,16 +566,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "easylistitaly.tpl", |
"query": "", |
"size": 85879, |
+ "referrer": "-", |
"ua": "Other", |
"uaversion": "", |
"fullua": "Other ", |
"clientid": "-", |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /notification.json?addonName=adblockpluschrome&addonVersion=1.5.3&application=chrome&applicationVersion=28.0.1500.72&platform=chromium&platformVersion=28.0.1500.72&lastVersion=201307292310 HTTP/1.1" 200 299 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36" "-" https', |
@@ -577,16 +586,17 @@ class Test(unittest.TestCase): |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "notification.json", |
"query": "addonName=adblockpluschrome&addonVersion=1.5.3&application=chrome&applicationVersion=28.0.1500.72&platform=chromium&platformVersion=28.0.1500.72&lastVersion=201307292310", |
"size": 299, |
+ "referrer": "-", |
"ua": "Chrome", |
"uaversion": "28.0", |
"fullua": "Chrome 28.0", |
"clientid": None, |
"addonName": "adblockpluschrome", |
"addonVersion": "1.5.3", |
"fullAddon": "adblockpluschrome 1.5.3", |
"application": "chrome", |
@@ -597,17 +607,24 @@ class Test(unittest.TestCase): |
"fullPlatform": "chromium 28.0", |
"downloadInterval": "1 day(s)", |
"previousDownload": "2 day(s)", |
"firstInDay": True, |
} |
), |
] |
for line, expected_record in tests: |
- self.assertEqual(logprocessor.parse_record(line, set(), FakeGeo(), FakeGeo()), expected_record, "Parsing log line '%s'" % line) |
+ result = logprocessor.parse_record(line, set(), FakeGeo(), FakeGeo()) |
+ # assertEqual() treats identical Unicode and non-Unicode strings as |
+ # 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,
|
+ if result: |
+ for key, value in result.iteritems(): |
+ if isinstance(value, unicode): |
+ result[key] = str(value) |
+ self.assertEqual(result, expected_record, "Parsing log line '%s'" % line) |
def test_record_adding(self): |
tests = [ |
( |
{"size": 200}, |
{}, |
(), |
{"hits": 1, "bandwidth": 200}, |