Chromium Code Reviews| Index: tools/metrics/actions/extract_actions_test.py |
| diff --git a/components/tools/metrics/count_ifdefs_unittest.py b/tools/metrics/actions/extract_actions_test.py |
| similarity index 16% |
| copy from components/tools/metrics/count_ifdefs_unittest.py |
| copy to tools/metrics/actions/extract_actions_test.py |
| index 9b8c3229a0f625b6eb0d3bd2b49982cb93d4e74a..1fef187d81db45a23bc798579cd532c82af58a44 100755 |
| --- a/components/tools/metrics/count_ifdefs_unittest.py |
| +++ b/tools/metrics/actions/extract_actions_test.py |
| @@ -1,29 +1,42 @@ |
| #!/usr/bin/env python |
| -# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +# 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.
|
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -"""Tests for count_ifdefs. |
| -""" |
| - |
| -import os |
| +import tempfile |
| import unittest |
| -import count_ifdefs |
| +import extract_actions |
| -class CountIfdefsTest(unittest.TestCase): |
| +ACTIONS_MOCK = """ |
| +<actions> |
| - def setUp(self): |
| - self.root = os.path.join(os.path.dirname(__file__), 'testdata') |
| +<action name="AboutChrome"> |
| + <owner>name1@google.com</owner> |
| + <owner>name2@google.com</owner> |
| + <description>Description.</description> |
| +</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
|
| + |
| +</actions> |
| +""" |
| - def testNormal(self): |
| - count = count_ifdefs.CountIfdefs('OS_[A-Z]+', self.root) |
| - self.failUnless(count == 6) |
| - def testSkipTests(self): |
| - count = count_ifdefs.CountIfdefs('OS_[A-Z]+', self.root, True) |
| - self.failUnless(count == 4) |
| +class ActionXmlTest(unittest.TestCase): |
| + |
| + def testReserveValue(self): |
| + with tempfile.NamedTemporaryFile(mode='w', delete=False) as f: |
| + f.write(ACTIONS_MOCK) |
| + file_name = f.name |
| + 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
|
| + self.assertEqual(1, len(actions)) |
| + self.assertEqual(1, len(actions_dict)) |
| + self.assertIn('AboutChrome', actions) |
| + self.assertIn('AboutChrome', actions_dict) |
| + self.assertEqual(2, len(actions_dict['AboutChrome'].owners)) |
| + self.assertIn('name1@google.com', actions_dict['AboutChrome'].owners) |
| + self.assertIn('name2@google.com', actions_dict['AboutChrome'].owners) |
| + self.assertEqual('Description.', actions_dict['AboutChrome'].description) |
| if __name__ == '__main__': |