"""Physical product change history functional tests.""" import json from oto.response import Response from ows_product_physical.logic import ownership def test_physical_product_change_history_successful( client, mocker, db_with_data, valid_post_header, db_release_id_with_history, valid_post_physical_product_change_history_fields_artwork, feature_engine): """Test successful update of product history change.""" mocker.patch.object( ownership, 'check_project_ownership', return_value=Response()) response = client.post( '/product/{}/change_history'.format(db_release_id_with_history), headers=valid_post_header, data=json.dumps( valid_post_physical_product_change_history_fields_artwork)) assert response.status_code == 201 def test_physical_product_change_history_validation_failure( client, mocker, db_with_data, db_release_id_with_history, valid_post_header, invalid_create_physical_product_change_history_field_name, feature_engine): """Test unsuccessful update of product history change.""" mocker.patch.object( ownership, 'check_project_ownership', return_value=Response()) response = client.post( '/product/{}/change_history'.format(db_release_id_with_history), headers=valid_post_header, data=json.dumps( invalid_create_physical_product_change_history_field_name)) assert response.status_code == 400 def test_physical_product_change_history_upc_owndership_failure( client, mocker, db_with_data, db_release_id_with_history, valid_post_header, invalid_create_physical_product_change_history_upc, feature_engine): """Test unsuccessful update of product history change.""" mocker.patch.object( ownership, 'check_project_ownership', return_value=Response()) response = client.post( '/product/{}/change_history'.format(db_release_id_with_history), headers=valid_post_header, data=json.dumps( invalid_create_physical_product_change_history_upc)) assert response.status_code == 400