def test_should_add_finished_product(self):
        finished_product = FinishedProduct(
            product_id=self.product.id,
            quantity=1,
            unit="pz"
        )
        finished_product.add()

        self.assertIn(finished_product, self.db.session)
示例#2
0
 def setUp(self):
     Test.setUp(self)
     self.product = Product(
         warehouse_id=1,
         code="Test Code",
         description="Optional description",
         price=10
     )
     self.product.add()
     self.finished_product = FinishedProduct(
         product_id=self.product.id,
         quantity=1,
         unit="pz"
     )
     self.finished_product.add()
示例#3
0
    def test_should_return_error_given_invalid_quantity(self):
        finished_product = FinishedProduct(product_id=self.product.id,
                                           quantity="Invalid Quantity",
                                           unit="pz")
        error = finished_product.validation.validate_nums()

        self.assertNotEqual(error, None)
示例#4
0
    def test_should_not_return_error_given_valid_finished_product(self):
        finished_product = FinishedProduct(product_id=self.product.id,
                                           quantity=1,
                                           unit="pz")
        error = finished_product.validation.validate()

        self.assertEqual(error, None)
示例#5
0
    def test_should_return_error_given_empty_unit(self):
        finished_product = FinishedProduct(product_id=self.product.id,
                                           quantity="1",
                                           unit="")
        error = finished_product.validation.validate_empty_values()

        self.assertNotEqual(error, None)
示例#6
0
    def test_should_not_add_finished_product_given_invalid_finished_product(
            self):
        finished_product = FinishedProduct(product_id=self.product.id,
                                           quantity="Invalid Quantity",
                                           unit="pz")
        finished_product.request.add()

        self.assertNotIn(finished_product, self.db.session)
示例#7
0
def profile(id):
    product = Product.query.get(id)
    form = get_form(finished_product_heads)
    if request.method == "POST":
        finished_product = FinishedProduct(product_id=product.id,
                                           unit=request.form["unit"],
                                           quantity=request.form["quantity"])
        error = finished_product.request.add()
        if error:
            flash(error)
        else:
            form = get_empty_form(finished_product_heads)

    return render_template('product/profile.html',
                           product_heads=product_heads,
                           finished_product_heads=finished_product_heads,
                           form=form,
                           product=product)
示例#8
0
 def setUp(self):
     ProductTest.setUp(self)
     finished_product = FinishedProduct(product_id=self.product.id,
                                        quantity=10,
                                        unit="pz")
     finished_product.add()
     sold_product = SoldProduct(receipt_id=1,
                                product_id=self.product.id,
                                unit="pz",
                                quantity=5,
                                price=self.product.price)
     sold_product.add()
     finished_product = FinishedProduct(product_id=self.product.id,
                                        quantity=10,
                                        unit="kg")
     finished_product.add()
     sold_product = SoldProduct(receipt_id=1,
                                product_id=self.product.id,
                                unit="kg",
                                quantity=5,
                                price=self.product.price)
     sold_product.add()