Home | History | Annotate | Download | only in tests
      1 #!/usr/bin/env python
      2 #
      3 #   copyright 2017 - the android open source project
      4 #
      5 #   licensed under the apache license, version 2.0 (the "license");
      6 #   you may not use this file except in compliance with the license.
      7 #   you may obtain a copy of the license at
      8 #
      9 #       http://www.apache.org/licenses/license-2.0
     10 #
     11 #   unless required by applicable law or agreed to in writing, software
     12 #   distributed under the license is distributed on an "as is" basis,
     13 #   without warranties or conditions of any kind, either express or implied.
     14 #   see the license for the specific language governing permissions and
     15 #   limitations under the license.
     16 
     17 import unittest
     18 
     19 from metrics import name_metric
     20 from tests import fake
     21 
     22 
     23 class NameMetricTest(unittest.TestCase):
     24     """Class for testing NameMetric."""
     25 
     26     def test_correct_name(self):
     27         stdout_string = "android1759-test-server-14"
     28         FAKE_RESULT = fake.FakeResult(stdout=stdout_string)
     29         fake_shell = fake.MockShellCommand(fake_result=FAKE_RESULT)
     30         metric_obj = name_metric.NameMetric(shell=fake_shell)
     31         expected_result = {
     32             name_metric.NameMetric.NAME: stdout_string,
     33         }
     34         self.assertEqual(expected_result, metric_obj.gather_metric())
     35 
     36 
     37 if __name__ == '__main__':
     38     unittest.main()
     39