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

Side by Side Diff: client/tests/isolateserver_test.py

Issue 2853413002: Add unit test to clean_caches() (Closed)
Patch Set: os.path.relpath Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/run_isolated.py ('k') | client/tests/run_isolated_smoke_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The LUCI Authors. All rights reserved. 2 # Copyright 2013 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 # pylint: disable=W0212,W0223,W0231,W0613 6 # pylint: disable=W0212,W0223,W0231,W0613
7 7
8 import base64 8 import base64
9 import hashlib 9 import hashlib
10 import json 10 import json
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 # Min free disk: 1000 bytes. 1329 # Min free disk: 1000 bytes.
1330 self._policies = isolateserver.CachePolicies(100, 1000, 2) 1330 self._policies = isolateserver.CachePolicies(100, 1000, 2)
1331 def get_free_space(p): 1331 def get_free_space(p):
1332 self.assertEqual(p, self.tempdir) 1332 self.assertEqual(p, self.tempdir)
1333 return self._free_disk 1333 return self._free_disk
1334 self.mock(file_path, 'get_free_space', get_free_space) 1334 self.mock(file_path, 'get_free_space', get_free_space)
1335 # TODO(maruel): Test the following. 1335 # TODO(maruel): Test the following.
1336 #cache.touch() 1336 #cache.touch()
1337 1337
1338 def get_cache(self): 1338 def get_cache(self):
1339 return isolateserver.DiskCache(self.tempdir, self._policies, self._algo) 1339 return isolateserver.DiskCache(
1340 self.tempdir, self._policies, self._algo, trim=True)
1340 1341
1341 def to_hash(self, content): 1342 def to_hash(self, content):
1342 return self._algo(content).hexdigest(), content 1343 return self._algo(content).hexdigest(), content
1343 1344
1344 def test_read_evict(self): 1345 def test_read_evict(self):
1345 self._free_disk = 1100 1346 self._free_disk = 1100
1346 h_a = self.to_hash('a')[0] 1347 h_a = self.to_hash('a')[0]
1347 with self.get_cache() as cache: 1348 with self.get_cache() as cache:
1348 cache.write(h_a, 'a') 1349 cache.write(h_a, 'a')
1349 with cache.getfileobj(h_a) as f: 1350 with cache.getfileobj(h_a) as f:
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 1472
1472 1473
1473 if __name__ == '__main__': 1474 if __name__ == '__main__':
1474 fix_encoding.fix_encoding() 1475 fix_encoding.fix_encoding()
1475 if '-v' in sys.argv: 1476 if '-v' in sys.argv:
1476 unittest.TestCase.maxDiff = None 1477 unittest.TestCase.maxDiff = None
1477 logging.basicConfig( 1478 logging.basicConfig(
1478 level=(logging.DEBUG if '-v' in sys.argv else logging.CRITICAL)) 1479 level=(logging.DEBUG if '-v' in sys.argv else logging.CRITICAL))
1479 clear_env_vars() 1480 clear_env_vars()
1480 unittest.main() 1481 unittest.main()
OLDNEW
« no previous file with comments | « client/run_isolated.py ('k') | client/tests/run_isolated_smoke_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698