Merge pull request 'fix: purchase summary test.' (#18) from fix_master_customer_test into main
Reviewed-on: #18
This commit is contained in:
		| @@ -2,6 +2,6 @@ | |||||||
| <dl> | <dl> | ||||||
| <dt>Date</dt> <dd>{{ purchase.date }}</dd> | <dt>Date</dt> <dd>{{ purchase.date }}</dd> | ||||||
| <dt>ID</dt> <dd>{{ purchase.id }}</dd> | <dt>ID</dt> <dd>{{ purchase.id }}</dd> | ||||||
| <dt>Customer</dt> <dd>{{ purchase.customer }}</dd> | <dt>Customer</dt> <dd>{{ purchase.customer.name }}</dd> | ||||||
| <dt>Total</dt> <dd>{{ purchase.get_total }}</dd> | <dt>Total</dt> <dd>{{ purchase.get_total }}</dd> | ||||||
| </dl> | </dl> | ||||||
|   | |||||||
| @@ -1,20 +1,24 @@ | |||||||
| from django.test import TestCase, Client | from django.test import TestCase, Client | ||||||
| from ..models import Sale, Product, SaleLine | from ..models import Sale, Product, SaleLine, Customer | ||||||
|  |  | ||||||
| class TestSummaryViewPurchase(TestCase): | class TestSummaryViewPurchase(TestCase): | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|  |         customer = Customer() | ||||||
|  |         customer.name = 'Alejo Mono' | ||||||
|  |         customer.save() | ||||||
|  |  | ||||||
|         self.client = Client() |         self.client = Client() | ||||||
|         purchase = Sale() |         purchase = Sale() | ||||||
|         purchase.customer = "Alejo Mono" |         purchase.customer = customer | ||||||
|         purchase.date = "2024-07-30" |         purchase.date = "2024-07-30" | ||||||
|         purchase.clean() |         purchase.clean() | ||||||
|         purchase.save() |         purchase.save() | ||||||
|          |  | ||||||
|         product = Product() |         product = Product() | ||||||
|         product.name = "cafe" |         product.name = "cafe" | ||||||
|         product.price = "72500" |         product.price = "72500" | ||||||
|         product.save() |         product.save() | ||||||
|          |  | ||||||
|         line = SaleLine() |         line = SaleLine() | ||||||
|         line.sale = purchase |         line.sale = purchase | ||||||
|         line.product = product |         line.product = product | ||||||
| @@ -22,10 +26,9 @@ class TestSummaryViewPurchase(TestCase): | |||||||
|         line.unit_price = "72500" |         line.unit_price = "72500" | ||||||
|         line.save() |         line.save() | ||||||
|         self.purchase = purchase |         self.purchase = purchase | ||||||
|          |  | ||||||
|     def test_summary_has_customer(self): |     def test_summary_has_customer(self): | ||||||
|         response = self.client.get("/don_confiao/resumen_compra/" + str(self.purchase.id)) |         response = self.client.get("/don_confiao/resumen_compra/" + str(self.purchase.id)) | ||||||
|         self.assertEqual(response.status_code, 200) |         self.assertEqual(response.status_code, 200) | ||||||
|         self.assertEqual(response.context["purchase"].customer, self.purchase.customer) |         self.assertEqual(response.context["purchase"].customer, self.purchase.customer) | ||||||
|         self.assertIn('Alejo Mono', response.content.decode('utf-8')) |         self.assertIn('Alejo Mono', response.content.decode('utf-8')) | ||||||
|          |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user