def test_product_edit(client, web2py): """ Can we edit a product? """ from populate_os_tables import populate_shop_products populate_shop_products(web2py) assert web2py.db(web2py.db.shop_products).count() == 1 url = '/shop_manage/product_edit?spID=1' client.get(url) assert client.status == 200 data = { 'id': '1', 'Name': 'Grapefruit', 'Description': 'Also great as juice', 'Visibility': 'in_stock' } client.post(url, data=data) assert client.status == 200 product = web2py.db.shop_products(1) assert product.Name == data['Name']
def test_products(client, web2py): """ Is the products page listing products? """ from populate_os_tables import populate_shop_products populate_shop_products(web2py) assert web2py.db(web2py.db.shop_products).count() == 1 url = '/shop_manage/products' client.get(url) assert client.status == 200 product = web2py.db.shop_products(1) assert product.Name in client.text
def test_product_variant_add(client, web2py): """ Can we add a product variant? """ from populate_os_tables import populate_shop_products, populate_tax_rates populate_shop_products(web2py) populate_tax_rates(web2py) assert web2py.db(web2py.db.shop_products).count() == 1 url = '/shop_manage/product_variant_add?spID=1' client.get(url) assert client.status == 200 data = {'id': '1', 'Name': 'Grapefruit', 'tax_rates_id': 1} client.post(url, data=data) assert client.status == 200 variant = web2py.db.shop_products_variants(1) assert variant.Name == data['Name']
def test_product_variant_add_with_products_set(client, web2py): """ We shouldn't be allowed to add a variant to a product with a set """ from populate_os_tables import populate_shop_products from populate_os_tables import populate_tax_rates from populate_os_tables import populate_shop_products_sets populate_shop_products_sets(web2py) populate_shop_products(web2py) populate_tax_rates(web2py) product = web2py.db.shop_products(1) product.shop_products_sets_id = 1 product.update_record() web2py.db.commit() assert web2py.db(web2py.db.shop_products).count() == 1 url = '/shop_manage/product_variant_add?spID=1' client.get(url) assert client.status == 200 assert "Unable to add" in client.text