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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # pylint: disable=relative-import,protected-access,unused-argument
3
4 # Copyright 2017 The WebRTC project authors. All Rights Reserved.
5 #
6 # Use of this source code is governed by a BSD-style license
7 # that can be found in the LICENSE file in the root of the source
8 # tree. An additional intellectual property rights grant can be found
9 # in the file PATENTS. All contributing project authors may
10 # be found in the AUTHORS file in the root of the source tree.
11
12 import os
13 import sys
14
15 SRC = os.path.abspath(os.path.join(
16 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.
17 sys.path.append(os.path.join(SRC, 'third_party', 'pymock'))
18
19 import unittest
20 import mock
kjellander_webrtc 2017/09/01 12:42:35 nit: sort alphabetically
sakal 2017/09/04 08:19:23 Done.
21
22 from generate_licenses import LicenseBuilder
23
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.
24 class TestLicenseBuilder(unittest.TestCase):
25 @staticmethod
26 def _FakeRunGN(buildfile_dir, target):
27 return """
28 {
29 "target1": {
30 "deps": [
31 "//a/b/third_party/libname1:c",
32 "//a/b/third_party/libname2:c(d)",
33 "//a/b/third_party/libname3/c:d(e)",
34 "//a/b/not_third_party/c"
35 ]
36 }
37 }
38 """
39
40 def testParseLibrary(self):
41 self.assertEquals(LicenseBuilder._ParseLibrary(
42 '//a/b/third_party/libname1:c').group(1),
43 'libname1')
44 self.assertEquals(LicenseBuilder._ParseLibrary(
45 '//a/b/third_party/libname2:c(d)').group(1),
46 'libname2')
47 self.assertEquals(LicenseBuilder._ParseLibrary(
48 '//a/b/third_party/libname3/c:d(e)').group(1),
49 'libname3')
50 self.assertEquals(LicenseBuilder._ParseLibrary('//a/b/not_third_party/c'),
51 None)
52
53 @mock.patch('generate_licenses.LicenseBuilder._RunGN', _FakeRunGN)
54 def testGetThirdPartyLibraries(self):
55 self.assertEquals(LicenseBuilder._GetThirdPartyLibraries(
56 'out/arm', 'target1'),
57 set(['libname1', 'libname2', 'libname3']))
58
59 if __name__ == '__main__':
60 unittest.main()
OLDNEW
« 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