| #!/usr/bin/env python |
| # |
| # copyright 2017 - the android open source project |
| # |
| # licensed under the apache license, version 2.0 (the "license"); |
| # you may not use this file except in compliance with the license. |
| # you may obtain a copy of the license at |
| # |
| # http://www.apache.org/licenses/license-2.0 |
| # |
| # unless required by applicable law or agreed to in writing, software |
| # distributed under the license is distributed on an "as is" basis, |
| # without warranties or conditions of any kind, either express or implied. |
| # see the license for the specific language governing permissions and |
| # limitations under the license. |
| |
| import unittest |
| |
| from metrics import name_metric |
| from tests import fake |
| |
| |
| class NameMetricTest(unittest.TestCase): |
| """Class for testing NameMetric.""" |
| |
| def test_correct_name(self): |
| stdout_string = "android1759-test-server-14" |
| FAKE_RESULT = fake.FakeResult(stdout=stdout_string) |
| fake_shell = fake.MockShellCommand(fake_result=FAKE_RESULT) |
| metric_obj = name_metric.NameMetric(shell=fake_shell) |
| expected_result = { |
| name_metric.NameMetric.NAME: stdout_string, |
| } |
| self.assertEqual(expected_result, metric_obj.gather_metric()) |
| |
| |
| if __name__ == '__main__': |
| unittest.main() |