[Erp5-report] r22901 - /erp5/trunk/products/ERP5/tests/testInvoice.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Aug 6 14:14:02 CEST 2008


Author: jerome
Date: Wed Aug  6 14:14:02 2008
New Revision: 22901

URL: http://svn.erp5.org?rev=22901&view=rev
Log:
test_CopyAndPaste can be applied to Sale & Purchase
more class hierarchy fixes

Modified:
    erp5/trunk/products/ERP5/tests/testInvoice.py

Modified: erp5/trunk/products/ERP5/tests/testInvoice.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testInvoice.py?rev=22901&r1=22900&r2=22901&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testInvoice.py (original)
+++ erp5/trunk/products/ERP5/tests/testInvoice.py Wed Aug  6 14:14:02 2008
@@ -45,6 +45,7 @@
 from testPackingList import TestPackingListMixin
 from testAccountingRules import TestAccountingRulesMixin
 
+
 class TestInvoiceMixin:
   """Test methods for invoices
   """
@@ -196,7 +197,8 @@
 
 
 class TestInvoice(TestInvoiceMixin):
-  """Test methods for invoice. Subclasses must defines portal types to use.
+  """Test methods for sale and purchase invoice.
+  Subclasses must defines portal types to use.
   """
   def test_invoice_transaction_line_resource(self):
     """
@@ -755,19 +757,41 @@
                     cell_child_32.getVariationCategoryList())
     self.assertTrue(cell_child_32.isMemberOf('size/Child/32'))
 
-
-class TestSaleInvoiceMixin(TestPackingListMixin,
+  def test_CopyAndPaste(self):
+    """Test copy on paste on Invoice.
+    When an invoice is copy/pasted, references should be resetted.
+    """
+    accounting_module = self.portal.accounting_module
+    invoice = accounting_module.newContent(
+                    portal_type=self.invoice_portal_type)
+    invoice.edit(reference='reference',
+                 source_reference='source_reference',
+                 destination_reference='destination_reference',)
+    cb_data = accounting_module.manage_copyObjects([invoice.getId()])
+    copied, = accounting_module.manage_pasteObjects(cb_data)
+    new_invoice = accounting_module[copied['new_id']]
+    self.assertNotEquals(invoice.getReference(),
+                         new_invoice.getReference())
+    self.assertNotEquals(invoice.getSourceReference(),
+                         new_invoice.getSourceReference())
+    self.assertNotEquals(invoice.getDestinationReference(),
+                         new_invoice.getDestinationReference())
+
+
+class TestSaleInvoiceMixin(TestInvoiceMixin,
+                           TestPackingListMixin,
                            TestAccountingRulesMixin,
-                           TestInvoice,
                            ERP5TypeTestCase):
   """Test sale invoice are created from orders then packing lists.
 
     Those tests methods only work for sale, because sale and purchase invoice
     are not built at the same time on packing list workflow.
   """
-  RUN_ALL_TESTS = 1
-  quiet = 1
-
+  invoice_portal_type = 'Sale Invoice Transaction'
+  invoice_line_portal_type = 'Invoice Line'
+  invoice_cell_portal_type = 'Invoice Cell'
+  invoice_transaction_line_portal_type = 'Sale Invoice Transaction Line'
+  
   # default sequence for one line of not varianted resource.
   PACKING_LIST_DEFAULT_SEQUENCE = """
       stepCreateEntities
@@ -1740,6 +1764,24 @@
     for applied_rule in applied_rule_set:
       checkTree(applied_rule)
 
+
+
+class TestSaleInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
+  """Tests for sale invoice.
+  """
+  RUN_ALL_TESTS = 1
+  quiet = 1
+
+  # fix inheritance
+  login = TestInvoiceMixin.login
+  createCategories = TestInvoiceMixin.createCategories
+
+  def _createCategories(self):
+    TestPackingListMixin.createCategories(self)
+    TestInvoiceMixin._createCategories(self)
+
+  getNeededCategoryList = TestInvoiceMixin.getNeededCategoryList
+
   def test_01_SimpleInvoice(self, quiet=quiet, run=RUN_ALL_TESTS):
     """
     Checks that a Simple Invoice is created from a Packing List
@@ -2457,29 +2499,6 @@
     # We could generate a better reference here.
     self.assertEquals('1', invoice.getReference())
     
-
-  def test_15_CopyAndPaste(self, run=RUN_ALL_TESTS):
-    """Test copy on paste on Invoice.
-    When an invoice is copy/pasted, references should be resetted.
-    """
-    if not run:
-      return
-    accounting_module = self.getAccountingModule()
-    invoice = accounting_module.newContent(
-                    portal_type=self.invoice_portal_type)
-    invoice.edit(reference='reference',
-                 source_reference='source_reference',
-                 destination_reference='destination_reference',)
-    cb_data = accounting_module.manage_copyObjects([invoice.getId()])
-    copied, = accounting_module.manage_pasteObjects(cb_data)
-    new_invoice = accounting_module[copied['new_id']]
-    self.assertNotEquals(invoice.getReference(),
-                         new_invoice.getReference())
-    self.assertNotEquals(invoice.getSourceReference(),
-                         new_invoice.getSourceReference())
-    self.assertNotEquals(invoice.getDestinationReference(),
-                         new_invoice.getDestinationReference())
-
   def test_16_ManuallyAddedMovements(self, quiet=quiet, run=RUN_ALL_TESTS):
     """
     Checks that adding invoice lines and accounting lines to one invoice
@@ -2560,24 +2579,6 @@
     sequence_list.play(self, quiet=quiet)
 
 
-class TestSaleInvoice(TestSaleInvoiceMixin, ERP5TypeTestCase):
-  """Tests for sale invoice.
-  """
-  invoice_portal_type = 'Sale Invoice Transaction'
-  invoice_line_portal_type = 'Invoice Line'
-  invoice_cell_portal_type = 'Invoice Cell'
-  invoice_transaction_line_portal_type = 'Sale Invoice Transaction Line'
-  
-  # fix inheritance
-  login = TestInvoiceMixin.login
-  createCategories = TestInvoiceMixin.createCategories
-
-  def _createCategories(self):
-    TestPackingListMixin.createCategories(self)
-    TestInvoiceMixin._createCategories(self)
-
-  getNeededCategoryList = TestInvoiceMixin.getNeededCategoryList
-
 
 class TestPurchaseInvoice(TestInvoice, ERP5TypeTestCase):
   """Tests for purchase invoice.




More information about the Erp5-report mailing list