class CustomerTest(Test): def setUp(self): Test.setUp(self) self.customer = Customer(customer_name="Test Name", address="Test Address", rfc="Test RFC") self.customer.add()
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): ReceiptTest.setUp(self) customer2 = Customer( customer_name="Name Two", address="Address Two", rfc="" ) customer2.add() self.create_test_users()
class ReceiptTest(Test): 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()
class TestUpdate(CustomerTest): 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_update_customer_given_valid_change(self): self.customer.customer_name = "New Name" self.customer.request.update() self.db.session.rollback() self.assertEqual(self.customer.customer_name, "New Name") def test_should_not_update_customer_given_invalid_change(self): self.customer2.rfc = "Test RFC" self.customer2.request.update() self.db.session.rollback() self.assertNotEqual(self.customer2.rfc, "Test RFC")