# Copyright The Linux Foundation and each contributor to CommunityBridge.
# SPDX-License-Identifier: MIT

import json
import os
import requests
import uuid

import hug
import pytest
from falcon import HTTP_200, HTTP_409

import cla
from cla import routes

ID_TOKEN = os.environ.get('ID_TOKEN')
API_URL = os.environ.get('API_URL')

def test_create_company_duplicate():
    """
     Test creating duplicate company names
    """
    import pdb;pdb.set_trace()
    url = f'{API_URL}/v1/company'
    company_name = 'test_company_name'
    data = {
        'company_id' : uuid.uuid4() ,
        'company_name' : company_name ,
    }
    headers = {
        'Authorization' : f'Bearer {ID_TOKEN}'
    }
    response = requests.post(url, data=data, headers=headers)
    assert response.status == HTTP_200

    # add duplicate company
    data = {
        'company_id' : uuid.uuid4(),
        'company_name' : company_name
    }
    req = hug.test.post(routes, url, data=data, headers=headers)
    assert req.status == HTTP_409

[((16, 11, 16, 37), 'os.environ.get', 'os.environ.get', ({(16, 26, 16, 36): '"""ID_TOKEN"""'}, {}), "('ID_TOKEN')", False, 'import os\n'), ((17, 10, 17, 35), 'os.environ.get', 'os.environ.get', ({(17, 25, 17, 34): '"""API_URL"""'}, {}), "('API_URL')", False, 'import os\n'), ((23, 15, 23, 30), 'pdb.set_trace', 'pdb.set_trace', ({}, {}), '()', False, 'import pdb\n'), ((33, 15, 33, 61), 'requests.post', 'requests.post', (), '', False, 'import requests\n'), ((41, 10, 41, 64), 'hug.test.post', 'hug.test.post', (), '', False, 'import hug\n'), ((27, 23, 27, 35), 'uuid.uuid4', 'uuid.uuid4', ({}, {}), '()', False, 'import uuid\n'), ((38, 23, 38, 35), 'uuid.uuid4', 'uuid.uuid4', ({}, {}), '()', False, 'import uuid\n')]