Pacify Linter
This commit is contained in:
@@ -4,7 +4,6 @@ Simple Grocery List (Sigl) | sigl.app
|
||||
Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
||||
"""
|
||||
|
||||
from nis import cat
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -141,7 +140,7 @@ def list_stores(session: Session, id: Optional[int]) -> List[str]:
|
||||
Product has locations are returned.
|
||||
"""
|
||||
if id is None:
|
||||
return list(set([l.store for l in session.query(ProductLocation).all()]))
|
||||
return list(set([loc.store for loc in session.query(ProductLocation).all()]))
|
||||
|
||||
sList = list_by_id(session, id)
|
||||
if not sList:
|
||||
@@ -307,6 +306,6 @@ def product_removeLocation(
|
||||
|
||||
for loc in product.locations:
|
||||
if loc.store.lower() == store.lower():
|
||||
session.delete(loc)
|
||||
session.delete(loc)
|
||||
|
||||
session.commit()
|
||||
|
||||
@@ -13,7 +13,6 @@ from sigl.exc import Error, NotFoundError
|
||||
from sigl.database import db
|
||||
from sigl.domain.service import (
|
||||
list_stores,
|
||||
product_update,
|
||||
products_all,
|
||||
product_by_id,
|
||||
product_create,
|
||||
@@ -68,11 +67,12 @@ def create():
|
||||
return redirect(url_for('products.detail', id=product.id))
|
||||
return render_template('products/create.html.j2')
|
||||
|
||||
|
||||
@bp.route('/products/<int:id>', methods=('GET', 'POST'))
|
||||
def detail(id):
|
||||
"""Product Detail/Editing View."""
|
||||
try:
|
||||
product = product_by_id(db.session, id);
|
||||
product = product_by_id(db.session, id)
|
||||
if not product:
|
||||
raise NotFoundError(f'Product {id} not found')
|
||||
|
||||
@@ -106,7 +106,6 @@ def detail(id):
|
||||
)
|
||||
|
||||
|
||||
|
||||
@bp.route('/products/<int:id>/delete', methods=('POST', ))
|
||||
def delete(id):
|
||||
"""Delete a Product."""
|
||||
|
||||
@@ -11,7 +11,6 @@ from alembic.config import Config
|
||||
import flask
|
||||
import pytest
|
||||
|
||||
import sigl
|
||||
from sigl.database import db as _db
|
||||
from sigl.factory import create_app
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ def test_product_model_init(session):
|
||||
def test_product_model_can_add_location(session):
|
||||
"""Test that a Location can be added to a Product."""
|
||||
p = Product(name='Eggs', category='Dairy')
|
||||
l = ProductLocation(product=p, store='Pavilions', aisle='Back Wall')
|
||||
loc = ProductLocation(product=p, store='Pavilions', aisle='Back Wall')
|
||||
|
||||
session.add(p)
|
||||
session.add(l)
|
||||
session.add(loc)
|
||||
session.commit()
|
||||
|
||||
assert l.aisle == 'Back Wall'
|
||||
assert l.bin is None
|
||||
assert l.product == p
|
||||
assert loc.aisle == 'Back Wall'
|
||||
assert loc.bin is None
|
||||
assert loc.product == p
|
||||
|
||||
assert l in p.locations
|
||||
assert loc in p.locations
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
|
||||
Reference in New Issue
Block a user