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