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

Side by Side Diff: tools/metrics/actions/extract_actions_test.py

Issue 149503005: Change actions.txt to actions.xml (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix function name. Created 6 years, 9 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
Ilya Sherman 2014/02/26 01:32:18 Ultra nit: Just "Copyright 2014" (i.e. no "(c)")
yao 2014/02/27 14:45:21 Done.
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 """Tests for count_ifdefs. 6 import tempfile
7 import unittest
8
9 import extract_actions
10
11
12 ACTIONS_MOCK = """
13 <actions>
14
15 <action name="AboutChrome">
16 <owner>name1@google.com</owner>
17 <owner>name2@google.com</owner>
18 <description>Description.</description>
19 </action>
Ilya Sherman 2014/02/26 01:32:18 Please test edge cases as well. What happens if t
yiyaoliu 2014/03/03 20:44:22 Edge cases like 0, 1, or more <owner>, <descriptio
yiyaoliu 2014/03/03 20:48:25 Sorry typo, there's no format requirement for <own
20
21 </actions>
7 """ 22 """
8 23
9 import os
10 import unittest
11 24
12 import count_ifdefs 25 class ActionXmlTest(unittest.TestCase):
13 26
14 27 def testReserveValue(self):
15 class CountIfdefsTest(unittest.TestCase): 28 with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
16 29 f.write(ACTIONS_MOCK)
17 def setUp(self): 30 file_name = f.name
18 self.root = os.path.join(os.path.dirname(__file__), 'testdata') 31 actions, actions_dict = extract_actions._ParseActionFile(file_name)
Ilya Sherman 2014/02/26 01:32:18 Rather than testing the internal function, it's mo
yao 2014/02/27 14:45:21 Could you give me a more concrete idea of how you
yao 2014/02/27 14:50:55 Actually I agree that if a function will be used a
Ilya Sherman 2014/03/01 00:58:14 I'm not going to be too picky about test coverage
19 32 self.assertEqual(1, len(actions))
20 def testNormal(self): 33 self.assertEqual(1, len(actions_dict))
21 count = count_ifdefs.CountIfdefs('OS_[A-Z]+', self.root) 34 self.assertIn('AboutChrome', actions)
22 self.failUnless(count == 6) 35 self.assertIn('AboutChrome', actions_dict)
23 36 self.assertEqual(2, len(actions_dict['AboutChrome'].owners))
24 def testSkipTests(self): 37 self.assertIn('name1@google.com', actions_dict['AboutChrome'].owners)
25 count = count_ifdefs.CountIfdefs('OS_[A-Z]+', self.root, True) 38 self.assertIn('name2@google.com', actions_dict['AboutChrome'].owners)
26 self.failUnless(count == 4) 39 self.assertEqual('Description.', actions_dict['AboutChrome'].description)
27 40
28 41
29 if __name__ == '__main__': 42 if __name__ == '__main__':
30 unittest.main() 43 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698