示例#1
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()
示例#2
0
 def test_should_not_add_receipt_given_empty_values_and_LUHP(self):
     self.login_user(self.admin_user)
     customer_data = dict(
         customer_name="",
         address="",
         phone=""
     )
     prev_receipts = Receipt.get_all()
     with self.client as client:
         client.post(
             url_for('receipt.add'),
             data=customer_data
         )
 
     self.assertEqual(Receipt.get_all(), prev_receipts)
示例#3
0
    def test_should_add_receipt_given_valid_customer_data_and_LUHP(self):
        self.login_user(self.admin_user)
        customer_data = dict(
            customer_name="Test Name",
            address="Test Address",
            phone="+123 456 7890"
        )
        prev_receipts = Receipt.get_all()
        with self.client as client:
            client.post(
                url_for("receipt.add"),
                data=customer_data
            )

        self.assertNotEqual(len(Receipt.get_all()), len(prev_receipts))
示例#4
0
 def test_should_add_receipt_and_new_customer_given_valid_customer_data_and_LUHP(self):
     self.login_user(self.admin_user)
     customer_data = dict(
         customer_name="Valid New Name",
         address="Valid Address",
         phone="+123 456 7890"
     )
     prev_receipts = Receipt.get_all()
     with self.client as client:
         client.post(
             url_for('receipt.add'),
             data=customer_data
         )
     
     self.assertNotEqual(len(Receipt.get_all()), len(prev_receipts))
     self.assertEqual(len(Customer.search_all('Valid New Name')), 1)
示例#5
0
    def test_should_add_receipt(self):
        receipt = Receipt(customer_id=self.customer.id)
        receipt.add()

        self.assertIn(receipt, self.db.session)
示例#6
0
    def test_should_return_list_of_all_receipts(self):
        receipts = Receipt.get_all()

        self.assertEqual(receipts, [self.receipt])
示例#7
0
    def test_should_return_none_given_invalid_id(self):
        receipt = Receipt.get(100)

        self.assertEqual(receipt, None)
示例#8
0
    def test_should_return_receipt_given_valid_id(self):
        receipt = Receipt.get(self.receipt.id)

        self.assertEqual(receipt, self.receipt)