Home | History | Annotate | Download | only in tests
      1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """This module contains unit tests for firmware_utils module."""
      6 
      7 import unittest
      8 
      9 import common_unittest_utils
     10 import firmware_utils
     11 
     12 
     13 class FirmwareUtilsTest(unittest.TestCase):
     14     """A class for firmware utils unit tests."""
     15 
     16     def test_get_fw_and_date(self):
     17         filenames = {
     18             # log directory names
     19             '20130422_020631-fw_1.0.170-manual':
     20                     ('fw_1.0.170', '20130422_020631'),
     21             '20130806_221321-fw_1.0.AA-robot':
     22                     ('fw_1.0.AA', '20130806_221321'),
     23 
     24             # gesture file names
     25             'rapid_taps_20.top_left-link-fw_1.0.AA-robot-20130806_223400.dat':
     26                     ('fw_1.0.AA', '20130806_223400'),
     27             'drumroll.fast-lumpy-fw_11.23-complete-20130710_063441.dat':
     28                     ('fw_11.23', '20130710_063441'),
     29         }
     30 
     31         for filename, (expected_fw, expected_date) in filenames.items():
     32             actual_fw, actual_date = firmware_utils.get_fw_and_date(filename)
     33             self.assertEqual(actual_fw, expected_fw)
     34             self.assertEqual(actual_date, expected_date)
     35 
     36 
     37 if __name__ == '__main__':
     38   unittest.main()
     39