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

Side by Side Diff: chrome/common/extensions/PRESUBMIT_test.py

Issue 10885049: Extensions Docs Server: KILL BUILD.PY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 import os.path 7 import os.path
8 import PRESUBMIT 8 import PRESUBMIT
9 9
10 10
(...skipping 23 matching lines...) Expand all
34 34
35 35
36 class TestPresubmit(unittest.TestCase): 36 class TestPresubmit(unittest.TestCase):
37 def setUp(self): 37 def setUp(self):
38 self.input_api = FakeInputApi() 38 self.input_api = FakeInputApi()
39 self.output_api = FakeOutputApi() 39 self.output_api = FakeOutputApi()
40 40
41 def assertPathsEqual(self, path1, path2): 41 def assertPathsEqual(self, path1, path2):
42 self.assertEqual(os.path.normpath(path1), os.path.normpath(path2)) 42 self.assertEqual(os.path.normpath(path1), os.path.normpath(path2))
43 43
44 def testCheckDocsChanges_NoFiles(self):
45 input_api = FakeInputApi(affected_files=[])
46 self.assertEqual([], PRESUBMIT.CheckDocChanges(input_api, self.output_api))
47
48 def testCheckDocsChanges_OnlyExcpetions(self):
49 input_api = FakeInputApi(affected_files=[
50 FakeAffectedFile(local_path='chrome/common/extensions/docs/README'),
51 FakeAffectedFile(local_path='chrome/common/extensions/docs/OWNERS')])
52 self.assertEqual([], PRESUBMIT.CheckDocChanges(input_api, self.output_api))
53
54 def testCheckDocsChanges_NoGeneratedFiles(self):
55 input_api = FakeInputApi(affected_files=[
56 FakeAffectedFile(
57 local_path='chrome/common/extensions/api/foo.json'),
58 FakeAffectedFile(
59 local_path='chrome/common/extensions/docs/examples/foo/b/bz.js'),
60 FakeAffectedFile(
61 local_path='chrome/common/extensions/docs/static/foo.html')])
62 expected_warning = (
63 'This change modifies the extension docs but the generated docs '
64 'have not been updated properly. See %s for more info.\n'
65 ' - Changes to %s not reflected in generated doc.\n'
66 ' - Changes to sample %s have not been re-zipped.\n'
67 ' - Docs out of sync with %s changes.\n'
68 'First build DumpRenderTree, then update the docs by running:\n %s'
69 ' --page-name=<apiName>' %
70 (os.path.normpath('chrome/common/extensions/docs/README.txt'),
71 os.path.normpath('chrome/common/extensions/docs/static/foo.html'),
72 os.path.normpath('chrome/common/extensions/docs/examples/foo/b/bz.js'),
73 os.path.normpath('chrome/common/extensions/api/foo.json'),
74 os.path.normpath('chrome/common/extensions/docs/build/build.py')))
75 self.assertEqual([expected_warning],
76 PRESUBMIT.CheckDocChanges(input_api, self.output_api))
77
78 def testCheckDocsChanges_OnlyGeneratedDocs(self):
79 input_api = FakeInputApi(affected_files=[
80 FakeAffectedFile(
81 local_path='chrome/common/extensions/docs/apps/foo.html'),
82 FakeAffectedFile(
83 local_path='chrome/common/extensions/docs/extensions/foo.html'),
84 FakeAffectedFile(
85 local_path='chrome/common/extensions/docs/apps/bar.html'),
86 FakeAffectedFile(
87 local_path='chrome/common/extensions/docs/extensions/baz.html')])
88 expected_warning = (
89 'This change modifies the extension docs but the generated docs '
90 'have not been updated properly. See %s for more info.\n'
91 ' - Changes to generated doc %s not reflected in non-generated files.\n'
92 ' - Changes to generated doc %s not reflected in non-generated files.\n'
93 ' - Changes to generated doc %s not reflected in non-generated files.\n'
94 ' - Changes to generated doc %s not reflected in non-generated files.\n'
95 'First build DumpRenderTree, then update the docs by running:\n %s'
96 ' --page-name=<apiName>' %
97 (os.path.normpath('chrome/common/extensions/docs/README.txt'),
98 os.path.normpath('chrome/common/extensions/docs/apps/bar.html'),
99 os.path.normpath('chrome/common/extensions/docs/apps/foo.html'),
100 os.path.normpath('chrome/common/extensions/docs/extensions/baz.html'),
101 os.path.normpath('chrome/common/extensions/docs/extensions/foo.html'),
102 os.path.normpath('chrome/common/extensions/docs/build/build.py')))
103 self.assertEqual([expected_warning],
104 PRESUBMIT.CheckDocChanges(input_api, self.output_api))
105
106 def testIsSkippedFile(self): 44 def testIsSkippedFile(self):
107 self.assertTrue(PRESUBMIT.IsSkippedFile( 45 self.assertTrue(PRESUBMIT.IsSkippedFile(
108 os.path.normpath('chrome/common/extensions/docs/README.txt'), 46 os.path.normpath('chrome/common/extensions/docs/README.txt'),
109 self.input_api)) 47 self.input_api))
110 self.assertTrue(PRESUBMIT.IsSkippedFile( 48 self.assertTrue(PRESUBMIT.IsSkippedFile(
111 os.path.normpath('chrome/common/extensions/OWNERS'), self.input_api)) 49 os.path.normpath('chrome/common/extensions/OWNERS'), self.input_api))
112 self.assertTrue(PRESUBMIT.IsSkippedFile( 50 self.assertTrue(PRESUBMIT.IsSkippedFile(
113 os.path.normpath('chrome/common/extensions/api/README'), 51 os.path.normpath('chrome/common/extensions/api/README'),
114 self.input_api)) 52 self.input_api))
115 self.assertTrue(PRESUBMIT.IsSkippedFile( 53 self.assertTrue(PRESUBMIT.IsSkippedFile(
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 local_path='chrome/common/extensions/docs/examples/foo/bar.jpg') 390 local_path='chrome/common/extensions/docs/examples/foo/bar.jpg')
453 zip_file = FakeAffectedFile( 391 zip_file = FakeAffectedFile(
454 local_path='chrome/common/extensions/docs/examples/baz.zip') 392 local_path='chrome/common/extensions/docs/examples/baz.zip')
455 input_api = FakeInputApi(affected_files=[sample_file, zip_file]) 393 input_api = FakeInputApi(affected_files=[sample_file, zip_file])
456 394
457 self.assertFalse(PRESUBMIT.SampleZipped(sample_file, input_api)) 395 self.assertFalse(PRESUBMIT.SampleZipped(sample_file, input_api))
458 396
459 397
460 if __name__ == '__main__': 398 if __name__ == '__main__':
461 unittest.main() 399 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698