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)
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)
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)
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)
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)
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)
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)
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)
def setUp(self): CustomerTest.setUp(self) self.customer2 = Customer( customer_name="Name Two", address="Address Two", rfc="RFC Two" ) self.customer2.add()
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)
def setUp(self): ReceiptTest.setUp(self) customer2 = Customer( customer_name="Name Two", address="Address Two", rfc="" ) customer2.add() self.create_test_users()
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)
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)
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()
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)
def setUp(self): Test.setUp(self) self.customer = Customer(customer_name="Test Name", address="Test Address", rfc="Test RFC") self.customer.add()