"""Integration tests for GET /companies and GET /brands endpoints.""" import requests from tests.integration import config from tests.integration.consts.api import BRANDS, COMPANIES KNR_COMPANY_BRAND_UUID = '77c6c150-19f3-451f-a692-1a5d7ef30e85' def test_get_companies_success(bearer_token_with_vendor_star) -> None: """GET /companies returns a list of companies.""" response = requests.get( COMPANIES, headers={'Authorization': f'Bearer {bearer_token_with_vendor_star}'}, ) assert response.status_code == 200 data = response.json() companies = data['companies'] assert isinstance(companies, list) assert len(data) >= 1 for company in companies: assert 'id' in company assert 'name' in company assert 'uuid' in company assert 'display_name' in company assert 'logo_url' in company assert 'parent_company_id' in company def test_get_companies_contains_known_brand(bearer_token_with_vendor_star) -> None: """GET /companies includes known QA brands.""" response = requests.get( COMPANIES, headers={ 'Authorization': f'Bearer {bearer_token_with_vendor_star}', 'Orchard-Requestor-Service': 'graphql-account', }, ) assert response.status_code == 200 data = response.json() companies = data['companies'] uuids = [company['uuid'] for company in companies] # theorchard company brand is always present assert KNR_COMPANY_BRAND_UUID in uuids def test_get_brands_fails_no_headers() -> None: """GET /brands fails with no profile headers.""" brands_response = requests.get( BRANDS, headers={ 'Orchard-Requestor-Service': 'graphql-account', }, ) assert brands_response.status_code == 403 def test_get_brands_success() -> None: """GET /brands returns the same list as /companies.""" brands_response = requests.get( BRANDS, headers={ 'Orchard-Requestor-Service': 'graphql-account', 'Orchard-Profile-Type': 'LabelProfile', 'Orchard-Roles': 'administrator', 'Orchard-Profile-Id': '123', 'Orchard-Identity-Id': 'abc', }, ) assert brands_response.status_code == 200 def test_get_company_success(bearer_token_with_vendor_star) -> None: """GET /companies/ returns the company.""" response = requests.get( f'{config.QA_BASE_URL}/companies/{KNR_COMPANY_BRAND_UUID}', headers={ 'Authorization': f'Bearer {bearer_token_with_vendor_star}', 'Orchard-Requestor-Service': 'graphql-account', }, ) assert response.status_code == 200 data = response.json() assert data['uuid'] == KNR_COMPANY_BRAND_UUID assert 'id' in data assert 'name' in data assert 'display_name' in data assert 'logo_url' in data assert 'parent_company_id' in data def test_get_company_not_found(bearer_token_with_vendor_star) -> None: """GET /companies/ returns 404 for unknown UUID.""" response = requests.get( f'{config.QA_BASE_URL}/companies/00000000-0000-0000-0000-000000000000', headers={ 'Authorization': f'Bearer {bearer_token_with_vendor_star}', 'Orchard-Requestor-Service': 'graphql-account', }, ) assert response.status_code == 404