Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Issue 126272: Add unit tests for watchlists (Closed)

Created:
11 years, 6 months ago by Nirnimesh
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Add unit tests for watchlists Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=18704

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 6

Patch Set 3 : '' #

Total comments: 14

Patch Set 4 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+147 lines, -3 lines) Patch
M PRESUBMIT.py View 1 chunk +1 line, -0 lines 0 comments Download
A tests/watchlists_unittest.py View 1 2 3 1 chunk +132 lines, -0 lines 0 comments Download
M watchlists.py View 1 2 3 1 chunk +14 lines, -3 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
Nirnimesh
11 years, 6 months ago (2009-06-17 13:20:24 UTC) #1
M-A Ruel
Please modify PRESUBMIT.py, add 'test.watchlists_unittest' to the unit tests to run. lgtm afterward http://codereview.chromium.org/126272/diff/1003/4 File ...
11 years, 6 months ago (2009-06-17 13:39:55 UTC) #2
Nirnimesh
http://codereview.chromium.org/126272/diff/1003/4 File tests/watchlists_unittest.py (right): http://codereview.chromium.org/126272/diff/1003/4#newcode19 Line 19: self.mox.StubOutWithMock(watchlists.Watchlists, '_ContentsOfWatchlistsFile') On 2009/06/17 13:39:55, Marc-Antoine Ruel wrote: ...
11 years, 6 months ago (2009-06-17 14:18:58 UTC) #3
M-A Ruel
lgtm
11 years, 6 months ago (2009-06-17 14:23:51 UTC) #4
John Grabowski
LGTM http://codereview.chromium.org/126272/diff/1005/11 File PRESUBMIT.py (right): http://codereview.chromium.org/126272/diff/1005/11#newcode18 Line 18: 'tests.watchlists_unittest', Hmm. Do we run all these ...
11 years, 6 months ago (2009-06-17 18:42:13 UTC) #5
M-A Ruel
http://codereview.chromium.org/126272/diff/1005/11 File PRESUBMIT.py (right): http://codereview.chromium.org/126272/diff/1005/11#newcode18 Line 18: 'tests.watchlists_unittest', On 2009/06/17 18:42:13, John Grabowski wrote: > ...
11 years, 6 months ago (2009-06-17 19:20:55 UTC) #6
Nirnimesh
11 years, 6 months ago (2009-06-18 03:23:40 UTC) #7
http://codereview.chromium.org/126272/diff/1005/9
File tests/watchlists_unittest.py (right):

http://codereview.chromium.org/126272/diff/1005/9#newcode9
Line 9: 
On 2009/06/17 18:42:13, John Grabowski wrote:
> extra space

Done.

http://codereview.chromium.org/126272/diff/1005/9#newcode10
Line 10: import super_mox
FWIW, mox on demand didn't really work for me. I ended up installing mox as
README.gclient_test said.

http://codereview.chromium.org/126272/diff/1005/9#newcode32
Line 32: contents = "some garbled and unwanted text"
On 2009/06/17 18:42:13, John Grabowski wrote:
> " --> '   for consistency
> 
> 

Done.

http://codereview.chromium.org/126272/diff/1005/9#newcode54
Line 54: watchlists.Watchlists._HasWatchlistsFile().AndReturn(True)
On 2009/06/17 18:42:13, John Grabowski wrote:
> Note python is dynamic, so for simple ops like this you can simply smack it
in. 
> E.g.
> watchlists.Watchlists._HasWatchlistsFile = lambda: True
> 
> 

Interesting. Thanks

http://codereview.chromium.org/126272/diff/1005/10
File watchlists.py (right):

http://codereview.chromium.org/126272/diff/1005/10#newcode55
Line 55: watchlists_file = open(self._GetRulesFilePath())
On 2009/06/17 18:42:13, John Grabowski wrote:
> """Comment for each function please."""
> Also, add a try block in case the file doesn't exist which returns an empty
> string and prints a warning.  Lack of a watchlist file shouldn't be a fatal
> error.
> 
> Perhaps then this becomes:
> try: 
>   return open(self._GetRulesFilePath()).read() # file closed when GC'd
> except IOError, e:
>   print 'Warning: no watchlist file ... '
>   return ''
> 

The only way to reach this fn call is to go through _HasWatchlistsFile() which
would block it.

ANyway, it's good to have a try block, in case of other reasons like file not
readable, etc...

Done

Powered by Google App Engine
This is Rietveld 408576698