"""ows-product-workflow unit tests.""" from owsrequest import request from owsrequest import test_utils from blacklist_manager.constants import service_name from blacklist_manager.models import ows_product_workflow def test_get_error_correction(monkeypatch, error_correction_data): """Test successful get error correction request.""" product_id = 1 path = '/product/{}/correction'.format(product_id) call_specs = [{ 'service': service_name.OWS_PRODUCT_WORKFLOW, 'path': path, 'status': 200, 'json': error_correction_data}] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(call_specs)) response = ows_product_workflow.get_error_corrections(product_id) assert response.status == 200 assert response.message == error_correction_data def test_get_error_correction_not_found(monkeypatch): """Test get error correction request not found.""" product_id = 1 path = '/product/{}/correction'.format(product_id) call_specs = [{ 'service': service_name.OWS_PRODUCT_WORKFLOW, 'path': path, 'status': 404, 'json': {'code': 'not_found_error'} }] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(call_specs)) response = ows_product_workflow.get_error_corrections(product_id) assert response.status == 200 assert response.message == {} def test_get_error_correction_failure(monkeypatch): """Test get error correction request not found.""" product_id = 1 path = '/product/{}/correction'.format(product_id) call_specs = [{ 'service': service_name.OWS_PRODUCT_WORKFLOW, 'path': path, 'status': 500, 'json': {'code': 'error'} }] monkeypatch.setattr( request, 'get', test_utils.mock_ows_requests(call_specs)) response = ows_product_workflow.get_error_corrections(product_id) assert response.status == 500 assert response.message == {'code': 'error'}