def setUp(self): Test.setUp(self) self.warehouse = Warehouse(name="Test Warehouse") self.warehouse.add() self.product = Product(warehouse_id=self.warehouse.id, code="Test Code", description="Optional description", price=10) self.product.add()
def test_should_add_warehouse_given_valid_warehouse_data_and_LUHP(self): self.login_user(self.dev_user) warehouse_data = dict(name="Valid name") with self.client as client: client.post(url_for('warehouse.add'), data=warehouse_data) self.assertNotEqual(Warehouse.search("Valid name"), None)
def test_should_not_return_error_given_valid_warehouse(self): warehouse = Warehouse( name="Valid name" ) error = warehouse.validation.validate() self.assertEqual(error, None)
def test_should_return_error_given_repeated_value(self): warehouse = Warehouse( name="Test Warehouse" ) error = warehouse.validation.validate_unique_values() self.assertNotEqual(error, None)
def test_should_not_return_error_given_unique_value(self): warehouse = Warehouse( name="Unique name" ) error = warehouse.validation.validate_unique_values() self.assertEqual(error, None)
def test_should_return_error_given_empty_value(self): warehouse = Warehouse( name="" ) error = warehouse.validation.validate_empty_values() self.assertNotEqual(error, None)
def inject_global_objects(): settings = get_settings() warehouses = Warehouse.get_all() customer_autocomplete_heads = [ "phone", "rfc" ] return dict( settings=settings, warehouses=warehouses, customer_autocomplete_heads=customer_autocomplete_heads )
def add(): form = get_form(warehouse_heads) if request.method == "POST": warehouse = Warehouse(name=form["name"]) error = warehouse.request.add() if not error: return redirect(url_for('warehouse.inventory', id=warehouse.id)) flash(error) return render_template( "warehouse/add.html", warehouse_heads=warehouse_heads, form=form, )
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_add_warehouse(self): warehouse = Warehouse(name="Another Test Warehouse") warehouse.add() self.assertIn(warehouse, self.db.session)
def test_should_return_warehouse_given_valid_search_term(self): warehouse = Warehouse.search('Test Warehouse') self.assertEqual(warehouse, self.warehouse)
def test_should_return_all_warehouses(self): warehouses = Warehouse.get_all() self.assertEqual(warehouses, [self.warehouse])
def test_should_return_warehouse_given_valid_id(self): warehouse = Warehouse.get(self.warehouse.id) self.assertEqual(warehouse, self.warehouse)
def setUp(self): Test.setUp(self) self.warehouse = Warehouse(name="Test Warehouse") self.warehouse.add()