Beispiel #1
0
 def test_download_successful(self, mock_copy):
     self.sync_call_config.get.return_value = False
     content_listener = listener.ContentListener(self.sync_conduit,
                                                 self.progress_report,
                                                 self.sync_call_config,
                                                 self.metadata_files)
     content_listener.download_succeeded(self.report)
     self.progress_report['content'].success.assert_called_once_with(
         self.report.data)
Beispiel #2
0
    def test_download_successful_with_validation(self, mock_copy,
                                                 mock_verify_size,
                                                 mock_verify_checksum,
                                                 mock_open):
        self.sync_call_config.get.return_value = True
        content_listener = listener.ContentListener(self.sync_conduit,
                                                    self.progress_report,
                                                    self.sync_call_config,
                                                    self.metadata_files)
        content_listener.download_succeeded(self.report)

        self.progress_report['content'].success.assert_called_once_with(
            self.report.data)
        mock_verify_size.assert_called_once()
        mock_verify_checksum.assert_called_once()
Beispiel #3
0
    def test_download_successful_invalid_checksum_verification(
            self, mock_copy, mock_verify_size, mock_verify_checksum,
            mock_open):
        self.sync_call_config.get.return_value = True

        mock_verify_checksum.side_effect = verification.VerificationException(
            'bad')
        content_listener = listener.ContentListener(self.sync_conduit,
                                                    self.progress_report,
                                                    self.sync_call_config,
                                                    self.metadata_files)

        content_listener.download_succeeded(self.report)

        mock_verify_checksum.assert_called_once()
        self.assertFalse(self.progress_report['content'].success.called)