refactoring(Purchase): simplify payment_method #47

This commit is contained in:
2024-11-09 13:49:24 -05:00
parent d5b7c99b79
commit b7c4cf5d44
4 changed files with 49 additions and 6 deletions

View File

@@ -1,4 +1,6 @@
from django.test import TestCase
from django.core.exceptions import ValidationError
from ..models import Customer, Product, Sale, SaleLine
@@ -24,6 +26,17 @@ class ConfiaoTest(TestCase):
self.assertIsInstance(sale, Sale)
def test_can_create_sale_without_payment_method(self):
sale = Sale()
sale.customer = self.customer
sale.date = "2024-06-22"
sale.phone = '666666666'
sale.description = "Description"
sale.payment_method = ''
with self.assertRaises(ValidationError):
sale.full_clean()
def test_create_sale_line(self):
sale = Sale()
sale.customer = self.customer

View File

@@ -19,6 +19,7 @@ class PurchaseFormTest(TestCase):
"csrfmiddlewaretoken": _csrf_token,
"customer": self.customer.id,
"date": "2024-08-03",
"payment_method": "CASH",
"phone": "sfasfd",
"description": "dasdadad",
"saleline_set-TOTAL_FORMS": "1",