def test_should_not_add_product_given_invalid_product_data_and_LUHP(self): self.login_user(self.admin_user) product_data = dict(code="", description="Some description", price="invalid price") with self.client as client: client.post(url_for("product.add", warehouse_id=1), data=product_data) self.assertEqual(len(Product.get_all()), 1)
def get_autocomplete_data(group, attribute): groups = dict( users=User.get_all(), products=Product.get_all(), customers = Customer.get_all(), expenses=Expense.get_all(), warehouses=Warehouse.get_all() ) data = [] for obj in groups[group]: value = getattr(obj, attribute) if value not in set(data): data.append(value) return data
def test_should_return_a_list_of_all_products(self): products = Product.get_all() self.assertEqual(products, [self.product])