"""Test application.""" from unittest.mock import patch import app from src.exceptions import InReviewQueueException from src.exceptions import OwsRequestException @patch('app.ows') def test_main(mock_ows): """Test main.""" actual = app.main() assert actual == {'success': '12345'} @patch('app.ows') def test_main_error_handling_in_queue(mock_ows): """Test main error handling.""" mock_ows.submit_products_by_id.side_effect = [ InReviewQueueException('12345') ] actual = app.main() assert actual == {'error': ('12345', 'Product already in review queue')} @patch('app.ows') def test_main_error_handling_ows(mock_ows): """Test main error handling.""" mock_ows.update_not_for_distribution.side_effect = [ OwsRequestException('update not_for_distribution', 'baz') ] actual = app.main() assert actual == { 'error': ('12345', 'Failed to call update not_for_distribution endpoint with error: baz')}