"""Functional tests of the HEAD product code endpoints. HEAD /vendor//product_code/ HEAD /subaccount//product_code/ """ from product.constants import header from tests.testutils import db def request_url(): """Request url for product_code.""" return '/{}/{}/product_code/{}' @db.test_schema def test_product_code_vendor(test_product, client): """Test product code check is successful for vendor.""" db.insert_vw_product() server_response = client.head(request_url().format( header.GRASS_ACCOUNT_TYPE_VENDOR, 1, 'prod-code')) assert server_response.status_code == 200 def test_product_code_bad_account_type(client): """Test ownership fails when invalid account type is provided.""" server_response = client.head( request_url().format('monkeys', 1, 1)) assert server_response.status_code == 400 @db.test_schema def test_product_code_not_found(test_product, client): """Test product code check is successful for vendor.""" db.insert_vw_product() server_response = client.head(request_url().format( header.GRASS_ACCOUNT_TYPE_VENDOR, 1, 'prod-code-not-found')) assert server_response.status_code == 404 @db.test_schema def test_product_code_vendor_exclude(test_product, client): """Test product code check is successful for vendor.""" db.insert_vw_product() url = request_url().format( header.GRASS_ACCOUNT_TYPE_VENDOR, 1, 'prod-code') server_response = client.head(url + '?exclude_product_id=1') assert server_response.status_code == 404