Browse Source

Moving test to tests.py

Alexandre Aubin 7 years ago
parent
commit
3f1444326a
2 changed files with 39 additions and 39 deletions
  1. 0 38
      coin/billing/models.py
  2. 39 1
      coin/billing/tests.py

+ 0 - 38
coin/billing/models.py

@@ -628,41 +628,3 @@ def payment_deleted(sender, instance, **kwargs):
     member.save()
 
 
-def test_accounting_update():
-
-    Member.objects.all().delete()
-    Payment.objects.all().delete()
-    Invoice.objects.all().delete()
-
-    johndoe =  Member.objects.create(username="johndoe",
-                                     first_name="John",
-                                     last_name="Doe",
-                                     email="johndoe@yolo.test")
-    johndoe.set_password("trololo")
-
-
-    # First facture
-    invoice = Invoice.objects.create(number="1337",
-                                     member=johndoe)
-    InvoiceDetail.objects.create(label="superservice",
-                                 amount="15.0",
-                                 invoice=invoice)
-    invoice.validate()
-
-    # Second facture
-    invoice2 = Invoice.objects.create(number="42",
-                                     member=johndoe)
-    InvoiceDetail.objects.create(label="superservice",
-                                 amount="42",
-                                 invoice=invoice2)
-    invoice2.validate()
-
-    # Payment
-    payment = Payment.objects.create(amount=20,
-                                     member=johndoe)
-
-    Member.objects.all().delete()
-    Payment.objects.all().delete()
-    Invoice.objects.all().delete()
-
-

+ 39 - 1
coin/billing/tests.py

@@ -9,7 +9,7 @@ from django.test import TestCase, Client
 from freezegun import freeze_time
 from coin.members.tests import MemberTestsUtils
 from coin.members.models import Member, LdapUser
-from coin.billing.models import Invoice, InvoiceQuerySet
+from coin.billing.models import Invoice, InvoiceQuerySet, InvoiceDetail, Payment
 from coin.offers.models import Offer, OfferSubscription
 from coin.billing.create_subscriptions_invoices import create_member_invoice_for_a_period
 from coin.billing.create_subscriptions_invoices import create_all_members_invoices_for_a_period
@@ -320,3 +320,41 @@ class InvoiceQuerySetTests(TestCase):
             bill.validate()
             self.assertEqual(bill.date, datetime.date(2017, 1, 1))
             self.assertEqual(bill.number, '2017-01-000001')
+
+
+class PaymentInvoiceAutoReconciliationTests(TestCase):
+
+    def test_accounting_update(self):
+
+        johndoe =  Member.objects.create(username=MemberTestsUtils.get_random_username(),
+                                         first_name="John",
+                                         last_name="Doe",
+                                         email="johndoe@yolo.test")
+        johndoe.set_password("trololo")
+
+        # First facture
+        invoice = Invoice.objects.create(number="1337",
+                                         member=johndoe)
+        InvoiceDetail.objects.create(label="superservice",
+                                     amount="15.0",
+                                     invoice=invoice)
+        invoice.validate()
+
+        # Second facture
+        invoice2 = Invoice.objects.create(number="42",
+                                         member=johndoe)
+        InvoiceDetail.objects.create(label="superservice",
+                                     amount="42",
+                                     invoice=invoice2)
+        invoice2.validate()
+
+        # Payment
+        payment = Payment.objects.create(amount=20,
+                                         member=johndoe)
+
+        invoice.delete()
+        invoice2.delete()
+        payment.delete()
+        johndoe.delete()
+
+