"""Functional tests for product_distribution creation.""" import json from ows_product_physical.constant import header from ows_product_physical.constant import service_name def test_save_product_distribution( client, valid_post_header, db_release_id, ows_request_mocker, db_with_data, product_distribution_data): """Test creation of product distribution data.""" expected_response = { 'status': 'success' } ows_request_mocker.mock_response( method='head', service=service_name.OWS_PRODUCT, path='/{}/{}/product/{}'.format( valid_post_header[header.GRASS_ACCOUNT_TYPE], valid_post_header[header.GRASS_ACCOUNT_ID], db_release_id )) client_response = client.post( '/product-distribution/{}'.format(db_release_id), headers=valid_post_header, data=json.dumps(product_distribution_data)) assert client_response.status_code == 200 actual_data = json.loads(client_response.data.decode('utf-8')) assert actual_data == expected_response