"""Tests for ows-carveouts-python model.""" from owsrequest import request from owsrequest import test_utils from product.constants import header from product.constants import service_name from product.models import ows_carveouts_python def test_delete_release_dms_master_carveout_success(monkeypatch): """Test delete_release_dms_master_carveout on successful deletion.""" product_id = 1 account_id = 1 account_type = 'vendor' path = '/release_dms_master_carveouts/{}'.format(product_id) call_specs = [{ 'service': service_name.OWS_CARVEOUTS_PYTHON, 'path': path, 'status': 200, 'header': { header.GRASS_ACCOUNT_TYPE: account_type, header.GRASS_ACCOUNT_ID: account_id } }] monkeypatch.setattr( request, 'delete', test_utils.mock_ows_requests(call_specs)) result = ows_carveouts_python.delete_release_dms_master_carveout(product_id) assert result.status == 200 def test_delete_release_dms_master_carveout_failure(monkeypatch): """Test delete_release_dms_master_carveout on failure.""" product_id = 1 account_id = '' account_type = '' path = '/release_dms_master_carveouts/{}'.format(product_id) call_specs = [{ 'service': service_name.OWS_CARVEOUTS_PYTHON, 'path': path, 'status': 500, 'header': { header.GRASS_ACCOUNT_TYPE: account_type, header.GRASS_ACCOUNT_ID: account_id } }] monkeypatch.setattr( request, 'delete', test_utils.mock_ows_requests(call_specs)) result = ows_carveouts_python.delete_release_dms_master_carveout(product_id) assert result.status == 500 def test_delete_release_dms_carveout_success(monkeypatch): """Test delete_release_dms_carveout on successful deletion.""" product_id = 1 account_id = 1 account_type = 'vendor' path = '/release_dms_carveouts/{}'.format(product_id) call_specs = [{ 'service': service_name.OWS_CARVEOUTS_PYTHON, 'path': path, 'status': 200, 'header': { header.GRASS_ACCOUNT_TYPE: account_type, header.GRASS_ACCOUNT_ID: account_id } }] monkeypatch.setattr( request, 'delete', test_utils.mock_ows_requests(call_specs)) result = ows_carveouts_python.delete_release_dms_carveout(product_id) assert result.status == 200 def test_delete_release_dms_carveout_failure(monkeypatch): """Test delete_release_dms_carveout on failure.""" product_id = 1 account_type = '' account_id = '' path = '/release_dms_carveouts/{}'.format(product_id) call_specs = [{ 'service': service_name.OWS_CARVEOUTS_PYTHON, 'path': path, 'status': 500, 'header': { header.GRASS_ACCOUNT_TYPE: account_type, header.GRASS_ACCOUNT_ID: account_id } }] monkeypatch.setattr( request, 'delete', test_utils.mock_ows_requests(call_specs)) result = ows_carveouts_python.delete_release_dms_carveout(product_id) assert result.status == 500