예제 #1
0
    def test_process_fw_on_calls__extract_fw_from_file(
            self, _extract_fw_from_file_mock, verify_checksum_mock,
            shutil_mock, os_mock, tempfile_mock):
        # | GIVEN |
        fw_processor = ilo_fw_processor.FirmwareProcessor(self.any_url)
        # Now mock the __download_fw_to method of fw_processor instance
        _download_fw_to_mock = mock.MagicMock()
        fw_processor._download_fw_to = _download_fw_to_mock

        expected_return_location = (ilo_fw_processor.FirmwareImageLocation(
            'some_location/file', 'file'))
        _extract_fw_from_file_mock.return_value = (expected_return_location,
                                                   True)
        node_mock = mock.ANY
        checksum_fake = mock.ANY
        # | WHEN |
        actual_return_location = fw_processor.process_fw_on(node_mock,
                                                            checksum_fake)
        # | THEN |
        _extract_fw_from_file_mock.assert_called_once_with(
            node_mock, os_mock.path.join.return_value)
        self.assertEqual(expected_return_location.fw_image_location,
                         actual_return_location.fw_image_location)
        self.assertEqual(expected_return_location.fw_image_filename,
                         actual_return_location.fw_image_filename)
        shutil_mock.rmtree.assert_called_once_with(
            tempfile_mock.mkdtemp(), ignore_errors=True)
예제 #2
0
 def test_fw_img_loc_sets_these_attributes(self):
     # | GIVEN |
     any_loc = 'some_location/some_fw_file'
     any_s_filename = 'some_fw_file'
     # | WHEN |
     location_obj = ilo_fw_processor.FirmwareImageLocation(
         any_loc, any_s_filename)
     # | THEN |
     self.assertEqual(any_loc, location_obj.fw_image_location)
     self.assertEqual(any_s_filename, location_obj.fw_image_filename)