Example #1
0
 def test_get_deviceinfo_emptydevice(self, mock_format_lscss, mock_utils):
     """
     unit test to validate _get_deviceinfo() with empty device i/p
     _get_deviceinfo() should return device
     """
     device = ""
     deviceinfo = utils._get_deviceinfo('', device)
     self.assertFalse(mock_utils.get_row_data.called,
                      msg='Unexpected call to mock_utils.get_row_data()')
     self.assertFalse(mock_format_lscss.called,
                      msg='Unexpected call to mock_format_lscss()')
     self.assertEqual(deviceinfo, device)
 def test_get_deviceinfo_emptydevice(self, mock_format_lscss, mock_utils):
     """
     unit test to validate _get_deviceinfo() with empty device i/p
     _get_deviceinfo() should return device
     """
     device = ""
     deviceinfo = utils._get_deviceinfo('', device)
     self.assertFalse(mock_utils.get_row_data.called,
                      msg='Unexpected call to mock_utils.get_row_data()')
     self.assertFalse(mock_format_lscss.called,
                      msg='Unexpected call to mock_format_lscss()')
     self.assertEqual(deviceinfo, device)
Example #3
0
 def test_get_deviceinfo_somedevice(self, mock_format_lscss,
                                    mock_get_row_data):
     """
     unit test to validate _get_deviceinfo() method with
     matching device
     _get_deviceinfo() should return _format_lscss() o/p
     """
     device = "xxx"
     header_pattern = "(Device)\s+(Subchan)\.\s+(DevType)\s+(CU\ Type)\s+" \
                      "(Use)\s+(PIM)\s+(PAM)\s+(POM)\s+(CHPIDs)$"
     device_pattern = "(xxx)\s+(\d\.\d\.[0-9a-fA-F]{4})\s+(\w+\/\w+)" \
                      "\s+(\w+\/\w+)\s(\s{3}|yes)\s+([0-9a-fA-F]{2})\s+" \
                      "([0-9a-fA-F]{2})\s+([0-9a-fA-F]{2})\s+(\w+\s\w+)"
     mock_get_row_data.return_value = {}
     mock_format_lscss.return_value = {}
     deviceinfo = utils._get_deviceinfo('', device)
     mock_get_row_data.assert_called_with('', header_pattern,
                                          device_pattern)
     mock_format_lscss.assert_called_with(mock_get_row_data.return_value)
     self.assertEqual(deviceinfo, {})
 def test_get_deviceinfo_somedevice(self, mock_format_lscss,
                                    mock_get_row_data):
     """
     unit test to validate _get_deviceinfo() method with
     matching device
     _get_deviceinfo() should return _format_lscss() o/p
     """
     device = "xxx"
     header_pattern = "(Device)\s+(Subchan)\.\s+(DevType)\s+(CU\ Type)\s+" \
                      "(Use)\s+(PIM)\s+(PAM)\s+(POM)\s+(CHPIDs)$"
     device_pattern = "(xxx)\s+(\d\.\d\.[0-9a-fA-F]{4})\s+(\w+\/\w+)" \
                      "\s+(\w+\/\w+)\s(\s{3}|yes)\s+([0-9a-fA-F]{2})\s+" \
                      "([0-9a-fA-F]{2})\s+([0-9a-fA-F]{2})\s+(\w+\s\w+)"
     mock_get_row_data.return_value = {}
     mock_format_lscss.return_value = {}
     deviceinfo = utils._get_deviceinfo('', device)
     mock_get_row_data.assert_called_with('', header_pattern,
                                          device_pattern)
     mock_format_lscss.assert_called_with(mock_get_row_data.
                                          return_value)
     self.assertEqual(deviceinfo, {})