Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DELETE no funciona #65

Open
mariomerlano opened this issue May 27, 2018 · 1 comment
Open

DELETE no funciona #65

mariomerlano opened this issue May 27, 2018 · 1 comment
Labels
question Further information is requested

Comments

@mariomerlano
Copy link

def test_order_product_DELETE(self):

    #Creo un producto
    producto = {
        'id':1,
        'name': 'Tenedor',
        'price': 50
    }
   
    self.client.post('/product', data=json.dumps(producto), content_type='application/json')

    #Creo una orden
    order = {
                    "id": 1 
            }
    
    order = Order()
    #Guardo la orden en la db directo ya que no está en endpoint en la api
    db.session.add(order)
    db.session.commit()

    orderProduct =  {"quantity":1,"product":{"id":1}}

    #Creo el OrderProduct
    self.client.post('/order/1/product', data=json.dumps(orderProduct), content_type='application/json')
    #Lo elimino
    self.client.delete('/order/1/product/1', data=json.dumps(orderProduct), content_type='application/json')
    p = Product.query.all()
    self.assertEqual(len(p), 0, "Hay productos, fallo el test")

Me tira que hay un producto:
E AssertionError: 1 != 0 : Hay productos, fallo el test

@RodrigoJacznik
Copy link
Contributor

Hola, el endpoint elimina un producto de una orden, vos en tu test estás controlando si el producto existe en la db, no si este existe en la orden.

@RodrigoJacznik RodrigoJacznik added the question Further information is requested label May 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants