"""Functional tests for PATCH /goals/{productId} endpoint.""" import json from sales_goals.models import sales_goal def test_sales_goal_update_with_hmv_notes( test_database, client, valid_post_header): """Test hmv notes are updated in the database.""" valid_post_header.pop('Grass-Account-Type') valid_post_header.pop('Grass-Account-Id') test_product_id = 1 sales_goal.create( product_id=test_product_id, updated_by=valid_post_header.get('Orchard-User-Id'), hmv_notes='old hmv notes') expected_result = 'new hmv notes' test_request_body = { 'hmv_notes': expected_result } result = client.patch( '/goals/{}'.format(test_product_id), headers=valid_post_header, data=json.dumps(test_request_body)) response_body = json.loads(result.get_data(as_text=True)) assert result.status_code == 200 assert response_body.get( 'sales_goals').get('hmv_notes') == expected_result