def test_POST_existing_client_email(db: Session) -> None:
    created = insert_client(db)

    client_data = {
        'name': random_upper_string(),
        'email': created.email,
        'last_name': random_upper_string(),
    }
    response = client.post('/api/v1/client/', json=client_data)

    created_client = response.json()
    assert response.status_code == 400
    assert "_id" not in created_client

    delete_client(db, created)
Exemple #2
0
def test_POST_existing_category_name(db: Session) -> None:
    created = insert_category(db)

    category_data = {
        'name': created.name,
        'description': random_upper_string(),
    }
    response = client.post('/api/v1/category/', json=category_data)

    created_category = response.json()
    assert response.status_code == 400
    assert "_id" not in created_category

    delete_category(db, created)
def test_POST_existing_product_name(db: Session) -> None:
    created = insert_product(db)

    product_data = {
        'name': created.name,
        'description': random_upper_string(),
        'tax_rate': 10,
        'brand_id': 1
    }
    response = client.post('/api/v1/product/', json=product_data)

    created_product = response.json()
    assert response.status_code == 400
    assert "_id" not in created_product

    delete_product(db, created)
def test_POST_existing_country_code(db: Session) -> None:
    country_create = create_random_country()
    created = crud.create(db, country_create)

    country_data = {
        'name': random_upper_string(),
        'code': country_create.code,
        'language': country_create.language,
        'currency': country_create.currency,
    }
    response = client.post('/api/v1/country/', json=country_data)

    created_country = response.json()
    assert response.status_code == 400
    assert "_id" not in created_country
    crud.remove(db, id=created.id)
Exemple #5
0
def test_POST_existing_province_name(db: Session) -> None:
    created = insert_province(db)

    province_data = {
        'name': created.name,
        'country_id': created.country_id,
        'region': random_upper_string(),
    }
    response = client.post('/api/v1/province/', json=province_data)

    created_country = response.json()
    assert response.status_code == 400
    assert "_id" not in response

    crud.province.remove(db, id=created.id)
    crud.country.remove(db, id=created.country_id)
Exemple #6
0
def test_POST_existing_prime_subscription_name(db: Session) -> None:
    created = insert_prime_subscription(db)

    prime_subscription_data = {
        'name': created.name,
        'validity': 1,
        'validity_type': random_upper_string(),
        'enabled': True
    }
    response = client.post('/api/v1/prime_subscription/',
                           json=prime_subscription_data)

    created_prime_subscription = response.json()
    assert response.status_code == 400
    assert "_id" not in created_prime_subscription

    delete_prime_subscription(db, created)
Exemple #7
0
def test_POST_existing_retailer_name(db: Session) -> None:
    created = insert_retailer(db)

    retailer_data = {
        'name': created.name,
        'description': random_upper_string(),
        'city_id': 1,
        'category_id': 1,
        'category_enabled': True,
    }
    response = client.post('/api/v1/retailer/', json=retailer_data)

    created_retailer = response.json()
    assert response.status_code == 400
    assert "_id" not in created_retailer

    delete_retailer(db, created)