示例#1
0
 def setUp(self):
     MyTest.setUp(self)
     self.customer = Customer(name="Test",
                              email="*****@*****.**",
                              phone="123 456 7890",
                              address="Test address")
     self.customer.add()
示例#2
0
 def setUp(self):
     CustomerRequestTest.setUp(self)
     self.customer2 = Customer(name="Test two",
                               email="*****@*****.**",
                               phone="222 456 7890",
                               address="Test address 2")
     self.customer2.add()
示例#3
0
 def setUp(self):
     CustomerValidationTest.setUp(self)
     self.customer2 = Customer(
         name="Test two",
         email="*****@*****.**",
         phone="321 654 0987",
         address="Test address two"
     )
     self.customer2.add()
示例#4
0
    def test_should_not_add_customer_given_invalid_customer(self):
        customer = Customer(name="",
                            email="*****@*****.**",
                            phone="123 456 7890",
                            address="Test address")
        customer_request = CustomerRequest(customer)
        customer_request.add()
        self.db.session.rollback()

        self.assertNotIn(customer, self.db.session)
示例#5
0
    def test_should_return_error_given_repeated_values(self):
        customer = Customer(
            name="Test",
            email="*****@*****.**",
            phone="123 456 7891",
            address="Test address"
        )
        customer_validation = CustomerValidation(customer)
        error = customer_validation.check_for_repeated_values()

        self.assertNotEqual(error, None)
示例#6
0
    def test_should_not_return_error_given_new_values(self):
        customer = Customer(
            name="Test two",
            email="*****@*****.**",
            phone="222 4444 7777",
            address="Test address two"
        )
        customer_validation = CustomerValidation(customer)
        error = customer_validation.check_for_repeated_values()

        self.assertEqual(error, None)
 def setUp(self):
     MyTest.setUp(self)
     self.quote = Quote.new(1)
     self.customer = Customer(
         name="Test",
         email="*****@*****.**",
         phone="123 456 7890",
         address="Test address"
     )
     self.customer.add()
     self.product = Product(
         quote_id=1,
         name="Test",
         material="Material",
         acabado="Acabado",
         cristal="Cristal"
     )
     self.product.add()
示例#8
0
def add():
    form = get_form(customer_heads)

    if request.method == 'POST':
        form = get_form(customer_heads)
        customer = Customer(name=form['name'],
                            email=form['email'],
                            phone=form['phone'],
                            address=form['address'])
        error = customer.request.add()

        if not error:
            return redirect(url_for('customer.customers'))

        flash(error)

    return render_template('customer/add.html',
                           heads=customer_heads,
                           form=form)
示例#9
0
def add():
    form = get_form(customer_heads)
    if request.method == "POST":
        error = None
        customer = search_for_customer(form)
        if not customer:
            customer = Customer(name=form['name'],
                                email=form['email'],
                                phone=form['phone'],
                                address=form['address'])
            error = customer.request.add()
        if not error:
            quote = Quote.new(customer.id)
            return redirect(url_for('quote.edit', id=quote.id))
        flash(error)

    return render_template(
        'quote/add.html',
        form=form,
        customer_heads=customer_heads,
        customer_placeholders=customer_placeholders,
    )