Index: sitescripts/stats/test/logprocessor.py |
=================================================================== |
--- a/sitescripts/stats/test/logprocessor.py |
+++ b/sitescripts/stats/test/logprocessor.py |
@@ -313,17 +313,16 @@ class Test(unittest.TestCase): |
class FakeGeo(object): |
def country_code_by_addr(self, ip): |
return "xy" |
tests = [ |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /devbuilds/adblockpluschrome/updates.xml?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 HTTP/1.1" 200 867 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36" "-" https" "en-US" "downloads.adblockplus.org" "-"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "devbuilds/adblockpluschrome/updates.xml", |
@@ -351,17 +350,16 @@ class Test(unittest.TestCase): |
), |
( |
'1.2.3.4 corrupted', |
None |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /devbuilds/abpcustomization/update.rdf?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 HTTP/1.1" 200 867 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20130730 Firefox/25.0" "-" https" "en-US" "downloads.adblockplus.org" "-"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "devbuilds/abpcustomization/update.rdf", |
@@ -377,17 +375,16 @@ class Test(unittest.TestCase): |
"application": "firefox", |
"applicationVersion": "25.0", |
"fullApplication": "firefox 25.0", |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /devbuilds/adblockplusie/update.json?addonName=adblockplusie&addonVersion=2.0&application=msie64&applicationVersion=10.0&platform=libadblockplus&platformVersion=1.0&lastVersion=0 HTTP/1.1" 200 867 "-" "Adblock Plus" "-" https" "en-US" "downloads.adblockplus.org" "-"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "devbuilds/adblockplusie/update.json", |
@@ -409,17 +406,16 @@ class Test(unittest.TestCase): |
"downloadInterval": "unknown", |
"previousDownload": "unknown", |
"firstDownload": True, |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /adblockplusandroid-1.1.2.apk HTTP/1.1" 200 49152 "https://adblockplus.org/en/android-install" "Mozilla/5.0 (Linux; U; Android 4.1.2; es-es; GT-I9100 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30" "-" https "en-US" "downloads.adblockplus.org" "-"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "adblockplusandroid-1.1.2.apk", |
@@ -430,17 +426,16 @@ class Test(unittest.TestCase): |
"fullua": "Mobile Safari 4.0", |
"clientid": "-", |
"installType": "install", |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /devbuilds/adblockplus/adblockplus-2.3.2.3712.xpi?update HTTP/1.1" 200 827261 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:22.0) Gecko/20100101 Firefox/22.0" "-" https', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"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", |
@@ -451,17 +446,16 @@ class Test(unittest.TestCase): |
"fullua": "Firefox 22.0", |
"clientid": None, |
"installType": "update", |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /exceptionrules.txt?addonName=adblockplus&addonVersion=2.3.2&application=firefox&applicationVersion=22.0&platform=gecko&platformVersion=22.0&lastVersion=201307311503 HTTP/1.1" 200 14303 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:22.0) Gecko/20100101 Firefox/22.0" "-" https "en-US,en;q=0.5" "easylist-downloads.adblockplus.org" "-"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "exceptionrules.txt", |
@@ -482,17 +476,16 @@ class Test(unittest.TestCase): |
"fullPlatform": "gecko 22.0", |
"downloadInterval": "2 hour(s)", |
"previousDownload": "same day", |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /easylist.txt?_=1375446528229 HTTP/1.1" 200 326120 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36" "-" https "nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4" "easylist-downloads.adblockplus.org" "AdBlock/2.6.2"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "easylist.txt", |
@@ -513,17 +506,16 @@ class Test(unittest.TestCase): |
"fullPlatform": "unknown unknown", |
"downloadInterval": "unknown", |
"previousDownload": "unknown", |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /easylistitaly.txt HTTP/1.1" 200 85879 "-" "-" "-" https "-" "easylist-downloads.adblockplus.org" "-"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "easylistitaly.txt", |
@@ -544,17 +536,16 @@ class Test(unittest.TestCase): |
"fullPlatform": "unknown unknown", |
"downloadInterval": "unknown", |
"previousDownload": "unknown", |
} |
), |
( |
'1.2.3.4 - - [31/Jul/2013:12:03:08 -0530] "GET /easylistitaly.tpl HTTP/1.1" 200 85879 "-" "-" "-" https "-" "easylist-downloads.adblockplus.org" "-"', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "easylistitaly.tpl", |
@@ -564,17 +555,16 @@ class Test(unittest.TestCase): |
"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', |
{ |
- "mirror": "mirror123", |
"ip": "1.2.3.4", |
"country": "xy", |
"time": datetime(2013, 7, 31, 17, 33, 8), |
"day": 31, |
"weekday": 2, |
"hour": 17, |
"month": "201307", |
"file": "notification.json", |
@@ -595,17 +585,16 @@ class Test(unittest.TestCase): |
"fullPlatform": "chromium 28.0", |
"downloadInterval": "1 day(s)", |
"previousDownload": "2 day(s)", |
"firstInDay": True, |
} |
), |
] |
for line, expected_record in tests: |
- logprocessor.mirror_name = "mirror123" |
self.assertEqual(logprocessor.parse_record(line, set(), FakeGeo(), FakeGeo()), expected_record, "Parsing log line '%s'" % line) |
def test_record_adding(self): |
tests = [ |
( |
{"size": 200}, |
{}, |
(), |