def test_download_sample_media_info_path_wrong(self, mock_os, mock_sample, mock_serve_download): """Test function download_sample_media_info with wrong path for media info.""" from mod_sample.controllers import (SampleNotFoundException, download_sample_media_info) mock_os.path.isfile.return_value = False with self.assertRaises(SampleNotFoundException): download_sample_media_info(1) mock_sample.query.filter.assert_called_once_with(mock_sample.id == 1) mock_os.path.isfile.assert_called_once()
def test_download_sample_media_info_sample_not_found( self, mock_os, mock_sample, mock_serve_download): """Test function download_sample_media_info to raise SampleNotFoundException.""" from mod_sample.controllers import (SampleNotFoundException, download_sample_media_info) mock_sample.query.filter.return_value.first.return_value = None with self.assertRaises(SampleNotFoundException): download_sample_media_info(1) mock_sample.query.filter.assert_called_once_with(mock_sample.id == 1) mock_os.path.isfile.assert_not_called()
def test_download_sample_media_info(self, mock_os, mock_sample, mock_serve_download): """Test function download_sample_media_info.""" from mod_sample.controllers import download_sample_media_info response = download_sample_media_info(1) self.assertEqual(response, mock_serve_download()) mock_sample.query.filter.assert_called_once_with(mock_sample.id == 1) mock_os.path.isfile.assert_called_once()