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

Unified Diff: tools_webrtc/libs/generate_licenses_test.py

Issue 3011613002: License generation script for build_aar.py. (Closed)
Patch Set: Add unittest Created 3 years, 3 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
Index: tools_webrtc/libs/generate_licenses_test.py
diff --git a/tools_webrtc/libs/generate_licenses_test.py b/tools_webrtc/libs/generate_licenses_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..4a9f651128317b8bb038c2d4e1c1cb0a5edad541
--- /dev/null
+++ b/tools_webrtc/libs/generate_licenses_test.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# pylint: disable=relative-import,protected-access,unused-argument
+
+# Copyright 2017 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS. All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+import os
+import sys
+
+SRC = os.path.abspath(os.path.join(
+ os.path.dirname((__file__)), os.pardir, os.pardir))
kjellander_webrtc 2017/09/01 12:42:35 indent align with above (
sakal 2017/09/04 08:19:23 Done.
+sys.path.append(os.path.join(SRC, 'third_party', 'pymock'))
+
+import unittest
+import mock
kjellander_webrtc 2017/09/01 12:42:35 nit: sort alphabetically
sakal 2017/09/04 08:19:23 Done.
+
+from generate_licenses import LicenseBuilder
+
kjellander_webrtc 2017/09/01 12:42:35 nit: 2 blank lines between each top-level statemen
sakal 2017/09/04 08:19:23 Done.
+class TestLicenseBuilder(unittest.TestCase):
+ @staticmethod
+ def _FakeRunGN(buildfile_dir, target):
+ return """
+ {
+ "target1": {
+ "deps": [
+ "//a/b/third_party/libname1:c",
+ "//a/b/third_party/libname2:c(d)",
+ "//a/b/third_party/libname3/c:d(e)",
+ "//a/b/not_third_party/c"
+ ]
+ }
+ }
+ """
+
+ def testParseLibrary(self):
+ self.assertEquals(LicenseBuilder._ParseLibrary(
+ '//a/b/third_party/libname1:c').group(1),
+ 'libname1')
+ self.assertEquals(LicenseBuilder._ParseLibrary(
+ '//a/b/third_party/libname2:c(d)').group(1),
+ 'libname2')
+ self.assertEquals(LicenseBuilder._ParseLibrary(
+ '//a/b/third_party/libname3/c:d(e)').group(1),
+ 'libname3')
+ self.assertEquals(LicenseBuilder._ParseLibrary('//a/b/not_third_party/c'),
+ None)
+
+ @mock.patch('generate_licenses.LicenseBuilder._RunGN', _FakeRunGN)
+ def testGetThirdPartyLibraries(self):
+ self.assertEquals(LicenseBuilder._GetThirdPartyLibraries(
+ 'out/arm', 'target1'),
+ set(['libname1', 'libname2', 'libname3']))
+
+if __name__ == '__main__':
+ unittest.main()
« tools_webrtc/libs/generate_licenses.py ('K') | « tools_webrtc/libs/generate_licenses.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698