Merge "Fix lint failures in cache warming."
diff --git a/cache_warming/cache_warming.py b/cache_warming/cache_warming.py
index 7b76fc3..e094d4a 100644
--- a/cache_warming/cache_warming.py
+++ b/cache_warming/cache_warming.py
@@ -13,6 +13,7 @@
import json
import os
import socket
+import dns.exception
import dns.resolver
hit_log = {}
@@ -104,7 +105,7 @@
for host in hosts:
try:
my_resolver.query(host)
- except:
+ except dns.exception.DNSException:
del hit_log[host]
hosts.remove(host)
diff --git a/cache_warming/cache_warming_test.py b/cache_warming/cache_warming_test.py
index 83ff1e8..220edc1 100644
--- a/cache_warming/cache_warming_test.py
+++ b/cache_warming/cache_warming_test.py
@@ -6,7 +6,7 @@
@wvtest.wvtest
-def testProcessQuery_firstHit():
+def test_process_query_first_hit():
qry = '123456789 www.yahoo.com'
expected = {'www.yahoo.com': (1, '123456789')}
cache_warming.hit_log = {}
@@ -16,7 +16,7 @@
@wvtest.wvtest
-def testProcessQuery_updateHitCount():
+def test_process_query_update_hit_count():
qry = '123456789 www.yahoo.com'
cache_warming.hit_log = {'www.yahoo.com': (1, '123456789')}
cache_warming.process_query(qry)
@@ -26,7 +26,7 @@
@wvtest.wvtest
-def testProcessQuery_updateRecentHitTime():
+def test_process_query_update_recent_hit_time():
qry = '123456789 www.yahoo.com'
cache_warming.hit_log = {'www.yahoo.com': (1, '987654321')}
cache_warming.process_query(qry)
@@ -36,7 +36,7 @@
@wvtest.wvtest
-def testSortHitLog_empty():
+def test_sort_hit_log_empty():
cache_warming.hit_log = {}
expected = []
actual = cache_warming.sort_hit_log()
@@ -44,7 +44,7 @@
@wvtest.wvtest
-def testSortHitLog_nonEmpty():
+def test_sort_hit_log_non_empty():
cache_warming.hit_log = {
'www.google.com': (2, '123456789'),
'www.yahoo.com': (1, '987654321'),
@@ -54,10 +54,11 @@
actual = cache_warming.sort_hit_log()
wvtest.WVPASSEQ(actual, expected)
+
@wvtest.wvtest
-def testHitLogSubset():
+def test_hit_log_subset():
hosts = ['www.google.com', 'www.yahoo.com']
- cache_warming.hit_log = cache_warming.hit_log = {
+ cache_warming.hit_log = cache_warming.hit_log = {
'www.youtube.com': (4, '987654321'),
'www.google.com': (1, '987654321'),
'www.espn.com': (3, '123456789'),