Closed Alexissiminkowich closed 6 years ago
Lo que deberías controlar es que la orden no cargue el producto. Vos estas controlando que no exista el producto.
Gracias! Ahi me di cuenta, cambie
prod = Product.query.all() por: prod = OrderProduct.query.all()
Ahora si, no se carga el prod, por lo que el test no da error. Faltaría algo mas?
Saludos!
Lo mejor es
prod = o.products
Sólo agarras los productos de la orden. Como lo hiciste vos agarra todas las filas de la tabla.
Ahi lo probe, gracias!!
Buenas tardes
Estoy trabajando con el punto 1.c de mi actividad, el de cargar un prod con cantidad negativa. Corre bien y llega al assert y da error, osea que deja cargar con cantidad negativa, le falta algo?
Logre lo siguiente:
El resultado me da:
Equipo@Equipo-PC MINGW32 ~/Desktop/ING DE SOFTWARE/orderingg (dev) $ pytest ============================= test session starts ============================= platform win32 -- Python 3.4.0, pytest-3.5.1, py-1.5.3, pluggy-0.6.0 rootdir: C:\Users\Equipo\Desktop\ING DE SOFTWARE\orderingg, inifile: collected 5 items
test\test_e2e.py F [ 20%] test\test_unit.py .... [100%]
================================== FAILURES =================================== ____ Ordering.test_solved_BUG_of_negative_quantity ____
self =
test\test_e2e.py:85: AssertionError ---------------------------- Captured stdout call ----------------------------- [Armario] ------------------------------ Captured log call ------------------------------ _internal.py 88 ERROR Error on request: Traceback (most recent call last): File "C:\Python34\lib\site-packages\werkzeug\serving.py", line 270, in run_wsg i execute(self.server.app) File "C:\Python34\lib\site-packages\werkzeug\serving.py", line 258, in execute application_iter = app(environ, start_response) File "C:\Python34\lib\site-packages\flask\app.py", line 1997, in call return self.wsgi_app(environ, start_response) File "C:\Python34\lib\site-packages\flask\app.py", line 1985, in wsgi_app response = self.handle_exception(e) File "C:\Python34\lib\site-packages\flask\app.py", line 1540, in handle_except ion reraise(exc_type, exc_value, tb) File "C:\Python34\lib\site-packages\flask_compat.py", line 33, in reraise raise value File "C:\Python34\lib\site-packages\flask\app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "C:\Python34\lib\site-packages\flask\app.py", line 1614, in full_dispatch _request rv = self.handle_user_exception(e) File "C:\Python34\lib\site-packages\flask\app.py", line 1517, in handle_user_e xception reraise(exc_type, exc_value, tb) File "C:\Python34\lib\site-packages\flask_compat.py", line 33, in reraise raise value File "C:\Python34\lib\site-packages\flask\app.py", line 1612, in full_dispatch _request rv = self.dispatch_request() File "C:\Python34\lib\site-packages\flask\app.py", line 1598, in dispatch_requ est return self.view_functionsrule.endpoint File "C:\Users\Equipo\Desktop\ING DE SOFTWARE\orderingg\app\routes.py", line 6 1, in addProductToOrder order = Order.query.get(pk) File "C:\Python34\lib\site-packages\sqlalchemy\orm\query.py", line 882, in get ident, loading.load_on_pk_identity) File "C:\Python34\lib\site-packages\sqlalchemy\orm\query.py", line 952, in _ge t_impl return db_load_fn(self, primary_key_identity) File "C:\Python34\lib\site-packages\sqlalchemy\orm\loading.py", line 247, in l oad_on_pk_identity return q.one() File "C:\Python34\lib\site-packages\sqlalchemy\orm\query.py", line 2884, in on e ret = self.one_or_none() File "C:\Python34\lib\site-packages\sqlalchemy\orm\query.py", line 2854, in on e_or_none ret = list(self) File "C:\Python34\lib\site-packages\sqlalchemy\orm\query.py", line 2925, in iter return self._execute_and_instances(context) File "C:\Python34\lib\site-packages\sqlalchemy\orm\query.py", line 2948, in _e xecute_and_instances result = conn.execute(querycontext.statement, self._params) File "C:\Python34\lib\site-packages\sqlalchemy\engine\base.py", line 948, in e xecute return meth(self, multiparams, params) File "C:\Python34\lib\site-packages\sqlalchemy\sql\elements.py", line 269, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "C:\Python34\lib\site-packages\sqlalchemy\engine\base.py", line 1060, in _execute_clauseelement compiled_sql, distilled_params File "C:\Python34\lib\site-packages\sqlalchemy\engine\base.py", line 1200, in _execute_context context) File "C:\Python34\lib\site-packages\sqlalchemy\engine\base.py", line 1413, in _handle_dbapi_exception exc_info File "C:\Python34\lib\site-packages\sqlalchemy\util\compat.py", line 203, in r aise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "C:\Python34\lib\site-packages\sqlalchemy\util\compat.py", line 186, in r eraise raise value.with_traceback(tb) File "C:\Python34\lib\site-packages\sqlalchemy\engine\base.py", line 1193, in _execute_context context) File "C:\Python34\lib\site-packages\sqlalchemy\engine\default.py", line 507, i n do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: order [SQL: 'SELECT "order".id AS order_id \nFROM "order" \nWHERE "order".id = ?'] [p arameters: ('1',)] (Background on this error at: http://sqlalche.me/e/e3q8) ===================== 1 failed, 4 passed in 27.54 seconds =====================