Commit e815727a authored by Rafael Monnerat's avatar Rafael Monnerat

Minor Fixups and add tests

See merge request !447
parents 1a2b1504 59ebd777
Pipeline #24699 failed with stage
in 0 seconds
# -*- coding: utf-8 -*-
# -*- coding: utf8 -*-
##############################################################################
#
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin, withAbort, simulate
from zExceptions import Unauthorized
......@@ -29,7 +51,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
)
@withAbort
def test_HS_calculateSubscriptionStartDate_REQUEST_disallowed(self):
def test_IT_calculateSubscriptionStartDate_REQUEST_disallowed(self):
item = self.createInstanceTree()
self.assertRaises(
Unauthorized,
......@@ -37,14 +59,14 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
REQUEST={})
@withAbort
def test_HS_calculateSubscriptionStartDate_noWorkflow(self):
def test_IT_calculateSubscriptionStartDate_noWorkflow(self):
item = self.createInstanceTree()
item.workflow_history['instance_slap_interface_workflow'] = []
date = item.InstanceTree_calculateSubscriptionStartDate()
self.assertEqual(date, item.getCreationDate().earliestTime())
@withAbort
def test_HS_calculateSubscriptionStartDate_withRequest(self):
def test_IT_calculateSubscriptionStartDate_withRequest(self):
item = self.createInstanceTree()
item.workflow_history['instance_slap_interface_workflow'] = [{
'comment':'Directly request the instance',
......@@ -58,7 +80,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.assertEqual(date, DateTime('2012/11/15'))
@withAbort
def test_HS_calculateSubscriptionStartDate_withRequestEndOfMonth(self):
def test_IT_calculateSubscriptionStartDate_withRequestEndOfMonth(self):
item = self.createInstanceTree()
item.workflow_history['instance_slap_interface_workflow'] = [{
'comment':'Directly request the instance',
......@@ -72,7 +94,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.assertEqual(date, DateTime('2012/11/30'))
@withAbort
def test_HS_calculateSubscriptionStartDate_withRequestAfterDestroy(self):
def test_IT_calculateSubscriptionStartDate_withRequestAfterDestroy(self):
item = self.createInstanceTree()
destroy_date = DateTime('2012/10/30 11:11')
request_date = DateTime('2012/11/30 11:11')
......@@ -97,7 +119,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.assertEqual(date, DateTime('2012/10/30'))
@withAbort
def test_HS_calculateSubscriptionStopDate_REQUEST_disallowed(self):
def test_IT_calculateSubscriptionStopDate_REQUEST_disallowed(self):
item = self.createInstanceTree()
self.assertRaises(
Unauthorized,
......@@ -105,7 +127,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
REQUEST={})
@withAbort
def test_HS_calculateSubscriptionStopDate_withDestroy(self):
def test_IT_calculateSubscriptionStopDate_withDestroy(self):
item = self.createInstanceTree()
destroy_date = DateTime('2012/10/30')
item.workflow_history['instance_slap_interface_workflow'].append({
......@@ -120,7 +142,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
self.assertEqual(date, DateTime('2012/10/31'))
@withAbort
def test_HS_calculateSubscriptionStopDate_noDestroy(self):
def test_IT_calculateSubscriptionStopDate_noDestroy(self):
item = self.createInstanceTree()
item.workflow_history['instance_slap_interface_workflow'] = []
date = item.InstanceTree_calculateSubscriptionStopDate()
......@@ -248,4 +270,77 @@ return context.getParentValue()""")
self.assertRaises(
Unauthorized,
sale_invoice_transaction.SaleInvoiceTransaction_resetPaymentMode,
REQUEST={})
\ No newline at end of file
REQUEST={})
def test_Person_get_set_AggregatedDelivery(self):
person = self.makePerson()
self.assertEqual(
person.Person_getAggregatedDelivery(), None)
delivery = self.portal.sale_packing_list_module.newContent(
portal_type="Sale Packing List")
person.Person_setAggregatedDelivery(delivery)
self.assertEqual(delivery,
person.Person_getAggregatedDelivery())
def test_AccountingTransactionModule_getUnpaidInvoiceList(self):
person = self.makePerson(user=1)
payment_template = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredDefaultPrePaymentTemplate())
payment = payment_template.Base_createCloneDocument(batch_mode=1)
for line in payment.contentValues():
if line.getSource() == "account_module/payment_to_encash":
line.setQuantity(-1)
elif line.getSource() == "account_module/receivable":
line.setQuantity(1)
payment.confirm()
payment.start()
template = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredDefaultPrePaymentSubscriptionInvoiceTemplate())
current_invoice = template.Base_createCloneDocument(batch_mode=1)
current_invoice.edit(
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
start_date=DateTime('2019/10/20'),
stop_date=DateTime('2019/10/20'),
title='Fake Invoice for Demo User Functional',
price_currency="currency_module/EUR",
reference='1')
cell = current_invoice["1"]["movement_0"]
cell.edit(quantity=1)
cell.setPrice(1)
payment.setCausalityValue(current_invoice)
payment.setDestinationSectionValue(person)
current_invoice.plan()
current_invoice.confirm()
current_invoice.startBuilding()
current_invoice.reindexObject()
current_invoice.stop()
self.tic()
self.login(person.getUserId())
self.assertEqual(
self.portal.accounting_module.AccountingTransactionModule_getUnpaidInvoiceList(),
[current_invoice])
self.login()
payment.stop()
self.tic()
self.login(person.getUserId())
self.assertEqual(
self.portal.accounting_module.AccountingTransactionModule_getUnpaidInvoiceList(),
[])
\ No newline at end of file
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSAccountingSkins</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
......@@ -49,6 +49,11 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
slapos_cloud/PreferenceTemplateItem/portal_preferences/slapos_default_system_preference.xml
slapos_cloud/PreferenceTemplateItem/portal_preferences/slapos_default_site_preference.xml
# Since the sections can be overwriten on project context, keep it on ignore list.
slapos_jio/PathTemplateItem/web_site_module/hostingjs/feed.xml
slapos_jio/PathTemplateItem/web_site_module/hostingjs/feed/critical.xml
slapos_jio/PathTemplateItem/web_site_module/hostingjs/feed/invoice.xml
# WebSite is updated after the installation to re-generate the translation data.
# This list should be reconsider later so we can keep information accurated.
slapos_jio/PathTemplateItem/web_site_module/hostingjs.xml
......@@ -174,8 +179,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_accounting/OrderBuilder_selectSlapOSAggregatedDeliveryList',
'slapos_accounting/PaymentTransaction_getExternalPaymentId',
'slapos_accounting/PaymentTransaction_postOrderBuild',
'slapos_accounting/Person_getAggregatedDelivery',
'slapos_accounting/Person_setAggregatedDelivery',
'slapos_accounting/SaleInvoiceTransaction_init',
'slapos_accounting/SaleInvoiceTransaction_isTotalPriceEqualAccounting',
'slapos_accounting/SaleInvoiceTransaction_isTotalPriceMatchingSalePackingList',
......
......@@ -99,6 +99,8 @@
<string>my_total_price</string>
<string>my_resource_title</string>
<string>my_payment_transaction_external_id</string>
<string>my_payment_state</string>
<string>my_payment_transaction</string>
</list>
</value>
</item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment