コード例 #1
0
    def test_should_return_error_given_repeated_rfc(self):
        customer = Customer(customer_name="Test Name",
                            address="Test Address",
                            rfc="Test RFC")
        error = customer.validation.validate_unique_values()

        self.assertNotEqual(error, None)
コード例 #2
0
    def test_should_not_return_error_given_valid_customer(self):
        customer = Customer(customer_name="Test Name",
                            address="Test Address",
                            rfc="Unique RFC")
        error = customer.validation.validate()

        self.assertEqual(error, None)
コード例 #3
0
    def test_should_not_return_error_given_empty_rfc(self):
        customer = Customer(customer_name="Test Name",
                            address="Test Address",
                            rfc="")
        error = customer.validation.validate_empty_values()

        self.assertEqual(error, None)
コード例 #4
0
    def test_should_return_error_given_invalid_phone(self):
        customer = Customer(customer_name="Test Name",
                            address="Test Address",
                            phone="invalid phone")
        error = customer.validation.validate_phone()

        self.assertNotEqual(error, None)
コード例 #5
0
    def test_should_return_error_given_empty_name(self):
        customer = Customer(customer_name="",
                            address="Test Address",
                            rfc="TESTRFC 123")
        error = customer.validation.validate_empty_values()

        self.assertNotEqual(error, None)
コード例 #6
0
    def test_should_not_return_error_given_valid_phone(self):
        customer = Customer(customer_name="Test Name",
                            address="Test Address",
                            phone="+442 303 2121")
        error = customer.validation.validate_phone()

        self.assertEqual(error, None)
コード例 #7
0
    def test_should_not_return_error_given_unique_name(self):
        customer = Customer(customer_name="Unique Name",
                            address="Test Address",
                            rfc="TESTRFC 123")
        error = customer.validation.validate_unique_value("customer_name")

        self.assertEqual(error, None)
コード例 #8
0
    def test_should_add_customer(self):
        customer = Customer(customer_name="Test Customer",
                            address="Test dirección",
                            rfc="Opcional RFC")
        customer.add()

        self.assertIn(customer, self.db.session)
コード例 #9
0
 def setUp(self):
     CustomerTest.setUp(self)
     self.customer2 = Customer(
         customer_name="Name Two",
         address="Address Two",
         rfc="RFC Two"
     )
     self.customer2.add()
コード例 #10
0
    def test_should_add_customer_given_valid_customer(self):
        customer = Customer(
            customer_name="Valid Name",
            address="Valid Address",
            rfc="Valid RFC"
        )
        customer.request.add()

        self.assertIn(customer, self.db.session)
コード例 #11
0
 def setUp(self):
     ReceiptTest.setUp(self)
     customer2 = Customer(
         customer_name="Name Two",
         address="Address Two",
         rfc=""
     )
     customer2.add()
     self.create_test_users()
コード例 #12
0
    def test_should_not_return_error_given_two_customers_with_empty_rfc(self):
        self.customer.rfc = ""
        self.customer.update()
        customer = Customer(customer_name="Valid Name",
                            address="Valid Address",
                            rfc="")
        error = customer.validation.validate_unique_values()

        self.assertEqual(error, None)
コード例 #13
0
    def test_should_not_return_error_given_two_customers_with_empty_name(self):
        self.customer.customer_name = ""
        self.customer.update()
        customer = Customer(customer_name="",
                            address="Valid Address",
                            rfc="Test RFC")
        error = customer.validation.validate_optional_unique_value(
            'customer_name')

        self.assertEqual(error, None)
コード例 #14
0
 def setUp(self):
     Test.setUp(self)
     self.customer = Customer(customer_name="Test Name",
                              address="Test Address",
                              rfc="Test RFC")
     self.customer.add()
     self.product_1 = Product(warehouse_id=1, code="Code 1", price=10)
     self.product_1.add()
     self.product_2 = Product(warehouse_id=1, code="Code 2", price=10)
     self.product_2.add()
     self.receipt = Receipt(customer_id=self.customer.id)
     self.receipt.add()
コード例 #15
0
ファイル: customer.py プロジェクト: ChrisPoul/Industrias-EnGo
def add():
    form = get_form(customer_heads)
    if request.method == 'POST':
        customer = Customer(customer_name=request.form['customer_name'],
                            address=request.form['address'],
                            phone=request.form['phone'],
                            rfc=request.form['rfc'])
        error = customer.request.add()
        if not error:
            return redirect(url_for('customer.customers'))
        flash(error)

    return render_template('customer/add.html',
                           customer_heads=customer_heads,
                           form=form)
コード例 #16
0
 def setUp(self):
     Test.setUp(self)
     self.customer = Customer(customer_name="Test Name",
                              address="Test Address",
                              rfc="Test RFC")
     self.customer.add()