"""Tests for handlers.""" import json from oto import response from ows_product_physical.constant import header from ows_product_physical.logic import product_physical def test_handler_put_update_product_supply_chain_info_success( client, valid_put_header, product_physical_supply_chain_update_record, mocker): """Test `PUT /product/{productId}/supply-chain-defaults` success.""" mocker.patch.object( product_physical, 'update_product_supply_chain_info', return_value=response.Response({}), autospec=True) result = client.put( '/product/123/supply-chain-defaults', headers=valid_put_header, data=json.dumps(product_physical_supply_chain_update_record)) assert result.status_code == 200 assert product_physical.update_product_supply_chain_info.called def test_handler_put_update_product_supply_chain_info_error( client, valid_get_header, product_physical_supply_chain_update_record): """Test `PUT /product/{productId}/tracks/publishing-obligation` fails. Should fail on invalid headers. """ invalid_header = valid_get_header invalid_header[header.GRASS_ACCOUNT_TYPE] = 'abc' result = client.put( '/product/123/supply-chain-defaults', headers=invalid_header, json=product_physical_supply_chain_update_record) assert result.status_code == 403