summary purchase: generate draft.

This commit is contained in:
2024-11-02 13:54:09 -05:00
parent 1519b3c8bb
commit b134b88791
3 changed files with 65 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
from django.test import TestCase, Client
from ..models import Sale, Product, SaleLine, Customer
class TestSummaryViewPurchase(TestCase):
def setUp(self):
customer = Customer()
@@ -22,20 +23,29 @@ class TestSummaryViewPurchase(TestCase):
line = SaleLine()
line.sale = purchase
line.product = product
line.quantity = "2"
line.quantity = "11"
line.unit_price = "72500"
line.save()
self.purchase = purchase
def test_summary_has_customer(self):
response = self.client.get("/don_confiao/resumen_compra/" + str(self.purchase.id))
url = "/don_confiao/resumen_compra/" + str(self.purchase.id)
response = self.client.get(url)
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'))
def test_json_summary(self):
response = self.client.get(f"/don_confiao/resumen_compra_json/{self.purchase.id}")
url = f"/don_confiao/resumen_compra_json/{self.purchase.id}"
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn('Alejo Mono', response.content.decode('utf-8'))
self.assertIn('cafe', response.content.decode('utf-8'))
self.assertIn('72500', response.content.decode('utf-8'))
self.assertIn('quantity', response.content.decode('utf-8'))
self.assertIn('11', response.content.decode('utf-8'))
self.assertIn('date', response.content.decode('utf-8'))
self.assertIn(self.purchase.date, response.content.decode('utf-8'))