コード例 #1
0
def test_list_all_client_carts(db: Session) -> None:
    client_cart_count = crud.client_cart.count(db)
    client_carts = crud.client_cart.filter(db)
    assert len(client_carts) == client_cart_count
    created = insert_client_cart(db)
    client_carts = crud.client_cart.filter(db)
    assert len(client_carts) == client_cart_count + 1
    delete_client_cart(db, created)
コード例 #2
0
def test_GET_existing_client_cart(db: Session) -> None:
    created = insert_client_cart(db)

    response = client.get(f'/api/v1/client_cart/{created.id}')
    client_cart_from_api = response.json()
    assert response.status_code == 200
    assert client_cart_from_api['client_id'] == created.client_id
    
    delete_client_cart(db, created)
コード例 #3
0
def test_update_client_cart(db: Session) -> None:
    created = insert_client_cart(db)
    client_cart_from_db = crud.client_cart.get_by_id(db, created.id)
    client_cart_update = ClientCartUpdate(client_id=8)
    updated_client_cart = crud.client_cart.update(
        db, db_object=client_cart_from_db, object_to_update=client_cart_update)
    client_cart_from_db = crud.client_cart.get_by_id(db, created.id)
    assert client_cart_from_db.id == updated_client_cart.id
    assert client_cart_from_db.client_id == 8
    delete_client_cart(db, created)
コード例 #4
0
def test_PUT_existing_client_cart(db: Session) -> None:
    created = insert_client_cart(db)

    client_cart_data = {'client_id': 9}

    response = client.put(f'/api/v1/client_cart/{created.id}', json=client_cart_data)
    client_cart_from_api = response.json()
    assert response.status_code == 200
    assert client_cart_from_api['client_id'] == 9
    
    delete_client_cart(db, created)
コード例 #5
0
def test_GET_client_cart(db: Session) -> None:
    client_cart_count = crud.client_cart.count(db)
    response = client.get('/api/v1/client_cart/')
    assert response.status_code == 200
    assert len(response.json()) == client_cart_count
    created = insert_client_cart(db)

    response = client.get('/api/v1/client_cart/')
    assert response.status_code == 200
    assert len(response.json()) == client_cart_count + 1
    
    delete_client_cart(db, created)
コード例 #6
0
def test_POST_new_valid_client_cart(db: Session, mocker) -> None:
    client_response = EurekaResponse(
        200, {'name': "Test", 'last_name': "Mock", 'id': 1, 'email': "*****@*****.**"})
    mocker.patch(
        'client.partner_client._partner_client_client.call_remote_service',
        return_value=client_response
    )

    client_cart_data = create_random_client_cart_data()
    response = client.post('/api/v1/client_cart/', json=client_cart_data)

    assert response.status_code == 200

    created_client_cart = response.json()
    cart_client_id = created_client_cart.get("id")

    client_cart_from_db = crud.client_cart.get_by_id(db, cart_client_id)

    assert client_cart_from_db
    assert client_cart_from_db.client_id == client_cart_data['client_id']
    
    delete_client_cart(db, client_cart_from_db)
コード例 #7
0
def test_create_client_cart(db: Session) -> None:
    created = insert_client_cart(db)
    client_cart_created = crud.client_cart.get_by_id(db, created.id)
    assert created.id == client_cart_created.id
    assert created.client_id == client_cart_created.client_id
    delete_client_cart(db, created)