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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/bots/zip_utils.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/bots/zip_utils_test.py
diff --git a/infra/bots/zip_utils_test.py b/infra/bots/zip_utils_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..4f88a115dfc32d537b225e8992925ae7a94c8c64
--- /dev/null
+++ b/infra/bots/zip_utils_test.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Tests for zip_utils."""
+
+
+import filecmp
+import os
+import test_utils
+import unittest
+import utils
+import uuid
+import zip_utils
+
+
+class ZipUtilsTest(unittest.TestCase):
+ def test_zip_unzip(self):
+ with utils.tmp_dir():
+ fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
+ # Create input files and directories.
+ fw.mkdir('mydir')
+ fw.mkdir('anotherdir', 0666)
+ fw.mkdir('dir3', 0600)
+ fw.mkdir('subdir')
+ fw.write('a.txt', 0777)
+ fw.write('b.txt', 0751)
+ fw.write('c.txt', 0640)
+ fw.write(os.path.join('subdir', 'd.txt'), 0640)
+
+ # Zip, unzip.
+ zip_utils.zip('input', 'test.zip')
+ zip_utils.unzip('test.zip', 'output')
+
+ # Compare the inputs and outputs.
+ test_utils.compare_trees(self, 'input', 'output')
+
+ def test_blacklist(self):
+ with utils.tmp_dir():
+ # Create input files and directories.
+ fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
+ fw.mkdir('.git')
+ fw.write(os.path.join('.git', 'index'))
+ fw.write('somefile')
+ fw.write('.DS_STORE')
+ fw.write('leftover.pyc')
+ fw.write('.pycfile')
+
+ # Zip, unzip.
+ zip_utils.zip('input', 'test.zip', blacklist=['.git', '.DS*', '*.pyc'])
+ zip_utils.unzip('test.zip', 'output')
+
+ # Remove the files/dirs we don't expect to see in output, so that we can
+ # use self._compare_trees to check the results.
+ fw.remove(os.path.join('.git', 'index'))
+ fw.remove('.git')
+ fw.remove('.DS_STORE')
+ fw.remove('leftover.pyc')
+
+ # Compare results.
+ test_utils.compare_trees(self, 'input', 'output')
+
+ def test_nonexistent_dir(self):
+ with utils.tmp_dir():
+ with self.assertRaises(IOError):
+ zip_utils.zip('input', 'test.zip')
+
+
+if __name__ == '__main__':
+ unittest.main()
« 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