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

Side by Side Diff: infra/bots/zip_utils_test.py

Issue 2069543002: Add asset management scripts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add asset_utils_test Created 4 years, 6 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 | « infra/bots/zip_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8
9 """Tests for zip_utils."""
10
11
12 import filecmp
13 import os
14 import test_utils
15 import unittest
16 import utils
17 import uuid
18 import zip_utils
19
20
21 class ZipUtilsTest(unittest.TestCase):
22 def test_zip_unzip(self):
23 with utils.tmp_dir():
24 fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
25 # Create input files and directories.
26 fw.mkdir('mydir')
27 fw.mkdir('anotherdir', 0666)
28 fw.mkdir('dir3', 0600)
29 fw.mkdir('subdir')
30 fw.write('a.txt', 0777)
31 fw.write('b.txt', 0751)
32 fw.write('c.txt', 0640)
33 fw.write(os.path.join('subdir', 'd.txt'), 0640)
34
35 # Zip, unzip.
36 zip_utils.zip('input', 'test.zip')
37 zip_utils.unzip('test.zip', 'output')
38
39 # Compare the inputs and outputs.
40 test_utils.compare_trees(self, 'input', 'output')
41
42 def test_blacklist(self):
43 with utils.tmp_dir():
44 # Create input files and directories.
45 fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
46 fw.mkdir('.git')
47 fw.write(os.path.join('.git', 'index'))
48 fw.write('somefile')
49 fw.write('.DS_STORE')
50 fw.write('leftover.pyc')
51 fw.write('.pycfile')
52
53 # Zip, unzip.
54 zip_utils.zip('input', 'test.zip', blacklist=['.git', '.DS*', '*.pyc'])
55 zip_utils.unzip('test.zip', 'output')
56
57 # Remove the files/dirs we don't expect to see in output, so that we can
58 # use self._compare_trees to check the results.
59 fw.remove(os.path.join('.git', 'index'))
60 fw.remove('.git')
61 fw.remove('.DS_STORE')
62 fw.remove('leftover.pyc')
63
64 # Compare results.
65 test_utils.compare_trees(self, 'input', 'output')
66
67 def test_nonexistent_dir(self):
68 with utils.tmp_dir():
69 with self.assertRaises(IOError):
70 zip_utils.zip('input', 'test.zip')
71
72
73 if __name__ == '__main__':
74 unittest.main()
OLDNEW
« no previous file with comments | « infra/bots/zip_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698