Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    def test_should_not_return_error_given_valid_warehouse(self):
        warehouse = Warehouse(
            name="Valid name"
        )
        error = warehouse.validation.validate()

        self.assertEqual(error, None)
Exemplo n.º 4
0
    def test_should_return_error_given_repeated_value(self):
        warehouse = Warehouse(
            name="Test Warehouse"
        )
        error = warehouse.validation.validate_unique_values()

        self.assertNotEqual(error, None)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    def test_should_return_error_given_empty_value(self):
        warehouse = Warehouse(
            name=""
        )
        error = warehouse.validation.validate_empty_values()

        self.assertNotEqual(error, None)
Exemplo n.º 7
0
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
    )
Exemplo n.º 8
0
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,
    )
Exemplo n.º 9
0
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
Exemplo n.º 10
0
    def test_should_add_warehouse(self):
        warehouse = Warehouse(name="Another Test Warehouse")
        warehouse.add()

        self.assertIn(warehouse, self.db.session)
Exemplo n.º 11
0
    def test_should_return_warehouse_given_valid_search_term(self):
        warehouse = Warehouse.search('Test Warehouse')

        self.assertEqual(warehouse, self.warehouse)
Exemplo n.º 12
0
    def test_should_return_all_warehouses(self):
        warehouses = Warehouse.get_all()

        self.assertEqual(warehouses, [self.warehouse])
Exemplo n.º 13
0
    def test_should_return_warehouse_given_valid_id(self):
        warehouse = Warehouse.get(self.warehouse.id)

        self.assertEqual(warehouse, self.warehouse)
Exemplo n.º 14
0
 def setUp(self):
     Test.setUp(self)
     self.warehouse = Warehouse(name="Test Warehouse")
     self.warehouse.add()