"""Functional tests of the HEAD /upc/available/ endpoint.""" from tests.factories.upc import UpcFactory from tests.testutils import db @db.test_schema def test_head_upc_not_found(client, test_upc): """Test that a 200 is returned if no product exists with the given UPC.""" upc_response = client.head('/upc/available/{}'.format(test_upc)) assert upc_response.status_code == 200 @db.test_schema def test_head_upc_found_upc(client, test_upc): """Test that a 404 is returned if a UPC exists with the given UPC.""" db.seed_models(UpcFactory.build(upc=test_upc)) upc_response = client.head('/upc/available/{}'.format(test_upc)) assert upc_response.status_code == 403 @db.test_schema def test_head_upc_found_product(client): """Test that a 404 is returned if a product exists with the given UPC.""" fixture_upc = 888831283041 db.insert_vw_product() upc_response = client.head('/upc/available/{}'.format(fixture_upc)) assert upc_response.status_code == 403