Commit b3aaf64e authored by Jérome Perrin's avatar Jérome Perrin

*: run 2to3 numliterals fixers

a modified version from nexedi/erp5$366
that supports patterns like
DateTime(2001, 02, 03) => DateTime(2001, 2, 3)
and not DateTime(2001, 0o2, 0o3)
parent 0048d09c
...@@ -5,7 +5,7 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery ...@@ -5,7 +5,7 @@ from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
portal = context.getPortalObject() portal = context.getPortalObject()
accounting_module = portal.accounting_module accounting_module = portal.accounting_module
year = 2005 year = 2005
default_date = DateTime(year, 01, 01) default_date = DateTime(year, 1, 1)
business_process = portal.portal_catalog.getResultValue( business_process = portal.portal_catalog.getResultValue(
reference=('default_erp5_business_process', # erp5_configurator reference=('default_erp5_business_process', # erp5_configurator
......
...@@ -98,8 +98,8 @@ for month in range(1, month_count + 1): ...@@ -98,8 +98,8 @@ for month in range(1, month_count + 1):
source_payment=getBankAccountByTitle('My default bank account'), source_payment=getBankAccountByTitle('My default bank account'),
destination_section=getOrganisationByTitle(client_title), destination_section=getOrganisationByTitle(client_title),
created_by_builder=1, created_by_builder=1,
start_date=DateTime(year, month, day, 01, 01) + 10, start_date=DateTime(year, month, day, 1, 1) + 10,
stop_date=DateTime(year, month, day, 01, 01) + 10, stop_date=DateTime(year, month, day, 1, 1) + 10,
causality_value=tr, causality_value=tr,
resource=euro_resource, resource=euro_resource,
) )
......
...@@ -208,7 +208,7 @@ class CertificateAuthorityTool(BaseTool): ...@@ -208,7 +208,7 @@ class CertificateAuthorityTool(BaseTool):
cert = os.path.join(self.certificate_authority_path, 'certs', cert = os.path.join(self.certificate_authority_path, 'certs',
new_id + '.crt') new_id + '.crt')
try: try:
os.close(os.open(key, os.O_CREAT | os.O_EXCL, 0600)) os.close(os.open(key, os.O_CREAT | os.O_EXCL, 0o600))
popenCommunicate([self.openssl_binary, 'req', '-utf8', '-nodes', '-config', popenCommunicate([self.openssl_binary, 'req', '-utf8', '-nodes', '-config',
self.openssl_config, '-new', '-keyout', key, '-out', csr, '-days', self.openssl_config, '-new', '-keyout', key, '-out', csr, '-days',
'3650'], '%s\n' % common_name, stdin=subprocess.PIPE) '3650'], '%s\n' % common_name, stdin=subprocess.PIPE)
......
...@@ -822,7 +822,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -822,7 +822,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
group='my_group') group='my_group')
accounting_period = organisation.newContent( accounting_period = organisation.newContent(
portal_type='Accounting Period', portal_type='Accounting Period',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2002, 12, 31)) stop_date=DateTime(2002, 12, 31))
self.assertEqual(accounting_period.getSimulationState(), 'draft') self.assertEqual(accounting_period.getSimulationState(), 'draft')
...@@ -1054,8 +1054,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1054,8 +1054,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepAccountingTransaction(self, sequence=None, sequence_list=None, **kw): def stepAccountingTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1186,8 +1186,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1186,8 +1186,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepSaleInvoiceTransaction(self, sequence=None, sequence_list=None, **kw): def stepSaleInvoiceTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1329,8 +1329,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1329,8 +1329,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepPurchaseInvoiceTransaction(self, sequence=None, sequence_list=None, **kw): def stepPurchaseInvoiceTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1476,8 +1476,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1476,8 +1476,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
def stepPaymentTransaction(self, sequence=None, sequence_list=None, **kw): def stepPaymentTransaction(self, sequence=None, sequence_list=None, **kw):
transaction = self.portal.accounting_module.newContent( transaction = self.portal.accounting_module.newContent(
portal_type='Payment Transaction', portal_type='Payment Transaction',
start_date=DateTime(2001, 01, 01), start_date=DateTime(2001, 1, 1),
stop_date=DateTime(2001, 01, 01)) stop_date=DateTime(2001, 1, 1))
self.assertEqual('draft', transaction.getSimulationState()) self.assertEqual('draft', transaction.getSimulationState())
for user_id in self._getUserIdList(self.all_username_list): for user_id in self._getUserIdList(self.all_username_list):
self.assertUserCanViewDocument(user_id, transaction) self.assertUserCanViewDocument(user_id, transaction)
...@@ -1621,29 +1621,29 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -1621,29 +1621,29 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
accounting_transaction_x_related_to_a = self.portal.\ accounting_transaction_x_related_to_a = self.portal.\
accounting_module.newContent( accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_y_related_to_a = self.portal.\ accounting_transaction_y_related_to_a = self.portal.\
accounting_module.newContent( accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_a = self.portal.accounting_module.newContent( accounting_transaction_a = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_b = self.portal.accounting_module.newContent( accounting_transaction_b = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_c = self.portal.accounting_module.newContent( accounting_transaction_c = self.portal.accounting_module.newContent(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime(2010, 06, 01), start_date=DateTime(2010, 6, 1),
stop_date=DateTime(2010, 06, 01)) stop_date=DateTime(2010, 6, 1))
accounting_transaction_x_related_to_a.setCausalityValue(\ accounting_transaction_x_related_to_a.setCausalityValue(\
accounting_transaction_a) accounting_transaction_a)
......
...@@ -138,7 +138,7 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -138,7 +138,7 @@ class TestAlarm(ERP5TypeTestCase):
right_first_date = DateTime(self.date_format % (2006,10,6,15,00,00)) right_first_date = DateTime(self.date_format % (2006,10,6,15,00,00))
now = DateTime(self.date_format % (2006,10,6,15,00,00)) now = DateTime(self.date_format % (2006,10,6,15,00,00))
right_second_date = DateTime(self.date_format % (2006,10,6,21,00,00)) right_second_date = DateTime(self.date_format % (2006,10,6,21,00,00))
right_third_date = DateTime(self.date_format % (2006,10,7,06,00,00)) right_third_date = DateTime(self.date_format % (2006,10,7,6,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,7,10,00,00)) right_fourth_date = DateTime(self.date_format % (2006,10,7,10,00,00))
alarm = self.newAlarm(enabled=True) alarm = self.newAlarm(enabled=True)
hour_list = (6,10,15,21) hour_list = (6,10,15,21)
...@@ -234,8 +234,8 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -234,8 +234,8 @@ class TestAlarm(ERP5TypeTestCase):
def test_09_SomeMonthDaysSomeHours(self): def test_09_SomeMonthDaysSomeHours(self):
"""- every 1st and 15th every month, at 12 and 14""" """- every 1st and 15th every month, at 12 and 14"""
right_first_date = DateTime(self.date_format % (2006,10,01,12,00,00)) right_first_date = DateTime(self.date_format % (2006,10,1,12,00,00))
right_second_date = DateTime(self.date_format % (2006,10,01,14,00,00)) right_second_date = DateTime(self.date_format % (2006,10,1,14,00,00))
right_third_date = DateTime(self.date_format % (2006,10,15,12,00,00)) right_third_date = DateTime(self.date_format % (2006,10,15,12,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,15,14,00,00)) right_fourth_date = DateTime(self.date_format % (2006,10,15,14,00,00))
alarm = self.newAlarm(enabled=True) alarm = self.newAlarm(enabled=True)
...@@ -247,9 +247,9 @@ class TestAlarm(ERP5TypeTestCase): ...@@ -247,9 +247,9 @@ class TestAlarm(ERP5TypeTestCase):
def test_10_OnceEvery2Month(self): def test_10_OnceEvery2Month(self):
"""- every 1st day of every 2 month, at 6""" """- every 1st day of every 2 month, at 6"""
right_first_date = DateTime(self.date_format % (2006,10,01,6,00,00)) right_first_date = DateTime(self.date_format % (2006,10,1,6,00,00))
right_second_date = DateTime(self.date_format % (2006,12,01,6,00,00)) right_second_date = DateTime(self.date_format % (2006,12,1,6,00,00))
right_third_date = DateTime(self.date_format % (2007,2,01,6,00,00)) right_third_date = DateTime(self.date_format % (2007,2,1,6,00,00))
alarm = self.newAlarm(enabled=True) alarm = self.newAlarm(enabled=True)
alarm.setPeriodicityStartDate(right_first_date) alarm.setPeriodicityStartDate(right_first_date)
alarm.setPeriodicityMonthDayList((1,)) alarm.setPeriodicityMonthDayList((1,))
......
...@@ -799,7 +799,7 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -799,7 +799,7 @@ class TestERP5Base(ERP5TypeTestCase):
"""Tests dates on Person objects. """Tests dates on Person objects.
""" """
pers = self.getPersonModule().newContent(portal_type='Person') pers = self.getPersonModule().newContent(portal_type='Person')
birthday = DateTime(1999, 01, 01) birthday = DateTime(1999, 1, 1)
now = DateTime() now = DateTime()
pers.edit(birthday = birthday) pers.edit(birthday = birthday)
self.assertEqual(birthday, pers.getBirthday()) self.assertEqual(birthday, pers.getBirthday())
...@@ -814,7 +814,7 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -814,7 +814,7 @@ class TestERP5Base(ERP5TypeTestCase):
"""Tests dates on Organisation objects. """Tests dates on Organisation objects.
""" """
org = self.getOrganisationModule().newContent(portal_type='Organisation') org = self.getOrganisationModule().newContent(portal_type='Organisation')
start_date = DateTime(1999, 01, 01) start_date = DateTime(1999, 1, 1)
now = DateTime() now = DateTime()
org.edit(start_date = start_date) org.edit(start_date = start_date)
self.assertEqual(start_date, org.getStartDate()) self.assertEqual(start_date, org.getStartDate())
...@@ -964,7 +964,7 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -964,7 +964,7 @@ class TestERP5Base(ERP5TypeTestCase):
subordination_value=first_organisation, subordination_value=first_organisation,
start_date=DateTime(1996, 9, 9)) start_date=DateTime(1996, 9, 9))
another_cancelled_career.cancel() another_cancelled_career.cancel()
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
person.Person_getCareerStartDate( person.Person_getCareerStartDate(
subordination_relative_url=first_organisation.getRelativeUrl())) subordination_relative_url=first_organisation.getRelativeUrl()))
......
...@@ -384,7 +384,7 @@ class TestDateTimeField(ERP5TypeTestCase): ...@@ -384,7 +384,7 @@ class TestDateTimeField(ERP5TypeTestCase):
.xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0]) .xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0])
def test_render_odt_variable(self): def test_render_odt_variable(self):
value = DateTime(2010, 12, 06, 10, 23, 32, 'GMT+5') value = DateTime(2010, 12, 6, 10, 23, 32, 'GMT+5')
self.field.values['default'] = value self.field.values['default'] = value
node = self.field.render_odt_variable(as_string=False) node = self.field.render_odt_variable(as_string=False)
self.assertEqual(node.get('{%s}value-type' % NSMAP['office']), 'date') self.assertEqual(node.get('{%s}value-type' % NSMAP['office']), 'date')
......
...@@ -280,7 +280,7 @@ class TestPreferences(PropertySheetTestCase): ...@@ -280,7 +280,7 @@ class TestPreferences(PropertySheetTestCase):
portal_workflow.doActionFor( portal_workflow.doActionFor(
person1, 'enable_action', wf_id='preference_workflow') person1, 'enable_action', wf_id='preference_workflow')
self.assertEqual(person1.getPreferenceState(), 'enabled') self.assertEqual(person1.getPreferenceState(), 'enabled')
person1.setPreferredAccountingTransactionAtDate(DateTime(2005, 01, 01)) person1.setPreferredAccountingTransactionAtDate(DateTime(2005, 1, 1))
pref_tool.setPreference( pref_tool.setPreference(
'preferred_accounting_transaction_at_date', DateTime(2004, 12, 31)) 'preferred_accounting_transaction_at_date', DateTime(2004, 12, 31))
self.tic() self.tic()
...@@ -320,7 +320,7 @@ class TestPreferences(PropertySheetTestCase): ...@@ -320,7 +320,7 @@ class TestPreferences(PropertySheetTestCase):
# create a pref for user_b # create a pref for user_b
user_b_1 = portal_preferences.newContent( user_b_1 = portal_preferences.newContent(
id='user_b_1', portal_type='Preference') id='user_b_1', portal_type='Preference')
user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 02, 02)) user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 2, 2))
self.tic() self.tic()
# enable this preference # enable this preference
......
...@@ -313,7 +313,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -313,7 +313,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
employee = sequence.get('employee') employee = sequence.get('employee')
model.edit(destination_section_value=employer, model.edit(destination_section_value=employer,
source_section_value=employee, source_section_value=employee,
effective_date=DateTime(2009,01,01), effective_date=DateTime(2009,1,1),
expiration_date=DateTime(2009,12,31), expiration_date=DateTime(2009,12,31),
version='001', version='001',
reference='basic_model', reference='basic_model',
...@@ -552,8 +552,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -552,8 +552,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
source_section_value=sequence.get('employee'), source_section_value=sequence.get('employee'),
destination_section_value=sequence.get('employer'), destination_section_value=sequence.get('employer'),
resource_value=sequence.get('price_currency'), resource_value=sequence.get('price_currency'),
start_date=DateTime(2009,06,01), start_date=DateTime(2009,6,1),
stop_date=DateTime(2009,06,30)) stop_date=DateTime(2009,6,30))
sequence.edit(paysheet = paysheet) sequence.edit(paysheet = paysheet)
def createPaysheetLine(self, document, **kw): def createPaysheetLine(self, document, **kw):
...@@ -1021,7 +1021,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1021,7 +1021,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
model.edit(\ model.edit(\
price_currency_value=currency, price_currency_value=currency,
default_payment_condition_trade_date='custom', default_payment_condition_trade_date='custom',
default_payment_condition_payment_date=DateTime(2009,05,25), default_payment_condition_payment_date=DateTime(2009,5,25),
work_time_annotation_line_quantity=151.67, work_time_annotation_line_quantity=151.67,
work_time_annotation_line_quantity_unit='time/hours', work_time_annotation_line_quantity_unit='time/hours',
) )
...@@ -1042,7 +1042,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1042,7 +1042,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
self.assertEqual(paysheet.getPriceCurrencyValue(), currency) self.assertEqual(paysheet.getPriceCurrencyValue(), currency)
self.assertEqual(paysheet.getDefaultPaymentConditionTradeDate(), 'custom') self.assertEqual(paysheet.getDefaultPaymentConditionTradeDate(), 'custom')
self.assertEqual(paysheet.getDefaultPaymentConditionPaymentDate(), self.assertEqual(paysheet.getDefaultPaymentConditionPaymentDate(),
DateTime(2009,05,25)) DateTime(2009,5,25))
self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantity(), 151.67) self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantity(), 151.67)
self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantityUnit(), self.assertEqual(paysheet.getWorkTimeAnnotationLineQuantityUnit(),
'time/hours') 'time/hours')
...@@ -1633,7 +1633,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1633,7 +1633,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 1, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 06, 30)) expiration_date=DateTime(2009, 6, 30))
model_1.validate() model_1.validate()
model_2 = self.getPortalObject().paysheet_model_module.newContent( \ model_2 = self.getPortalObject().paysheet_model_module.newContent( \
...@@ -1641,7 +1641,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1641,7 +1641,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31)) expiration_date=DateTime(2009, 12, 31))
model_2.validate() model_2.validate()
...@@ -1672,8 +1672,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1672,8 +1672,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model_1, specialise_value=model_1,
start_date=DateTime(2009, 07, 1), start_date=DateTime(2009, 7, 1),
stop_date=DateTime(2009, 07, 31), stop_date=DateTime(2009, 7, 31),
price_currency_value=eur) price_currency_value=eur)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.tic() self.tic()
...@@ -1701,8 +1701,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1701,8 +1701,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 02, 28), expiration_date=DateTime(2009, 2, 28),
specialise_value=sequence.get('business_process')) specialise_value=sequence.get('business_process'))
model_1.validate() model_1.validate()
...@@ -1712,7 +1712,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1712,7 +1712,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='002', version='002',
specialise_value=sequence.get('business_process')) specialise_value=sequence.get('business_process'))
...@@ -1722,7 +1722,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1722,7 +1722,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
variation_settings_category_list=['salary_range/france',], variation_settings_category_list=['salary_range/france',],
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001', version='001',
specialise_value=sequence.get('business_process')) specialise_value=sequence.get('business_process'))
...@@ -1733,8 +1733,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1733,8 +1733,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model_1, specialise_value=model_1,
start_date=DateTime(2009, 07, 1), start_date=DateTime(2009, 7, 1),
stop_date=DateTime(2009, 07, 31), stop_date=DateTime(2009, 7, 31),
price_currency_value=eur) price_currency_value=eur)
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.tic() self.tic()
...@@ -1796,8 +1796,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1796,8 +1796,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 02, 28)) expiration_date=DateTime(2009, 2, 28))
model_line_1 = self.createModelLine(model_1) model_line_1 = self.createModelLine(model_1)
model_line_1.edit( model_line_1.edit(
resource_value=labour, resource_value=labour,
...@@ -1812,7 +1812,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1812,7 +1812,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='002') version='002')
model_line_2 = self.createModelLine(model_2) model_line_2 = self.createModelLine(model_2)
...@@ -1827,7 +1827,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1827,7 +1827,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_2009', reference='fabien_model_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001') version='001')
model_line_3 = self.createModelLine(model_3) model_line_3 = self.createModelLine(model_3)
...@@ -1844,8 +1844,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1844,8 +1844,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_2_2009', reference='fabien_model_level_2_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 06, 30), expiration_date=DateTime(2009, 6, 30),
version='002') version='002')
model_line_4 = self.createModelLine(model_4) model_line_4 = self.createModelLine(model_4)
model_line_4.edit( model_line_4.edit(
...@@ -1859,7 +1859,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1859,7 +1859,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_2_2009', reference='fabien_model_level_2_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001') version='001')
model_line_5 = self.createModelLine(model_5) model_line_5 = self.createModelLine(model_5)
...@@ -1876,8 +1876,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1876,8 +1876,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_3_2009', reference='fabien_model_level_3_2009',
effective_date=DateTime(2009, 01, 1), effective_date=DateTime(2009, 1, 1),
expiration_date=DateTime(2009, 06, 30), expiration_date=DateTime(2009, 6, 30),
version='002') version='002')
model_line_6 = self.createModelLine(model_6) model_line_6 = self.createModelLine(model_6)
model_line_6.edit( model_line_6.edit(
...@@ -1891,7 +1891,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1891,7 +1891,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_3_2009', reference='fabien_model_level_3_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001') version='001')
model_line_7 = self.createModelLine(model_7) model_line_7 = self.createModelLine(model_7)
...@@ -1907,7 +1907,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1907,7 +1907,7 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
portal_type='Pay Sheet Model', portal_type='Pay Sheet Model',
specialise_value=sequence.get('business_process'), specialise_value=sequence.get('business_process'),
reference='fabien_model_level_3_2009', reference='fabien_model_level_3_2009',
effective_date=DateTime(2009, 07, 1), effective_date=DateTime(2009, 7, 1),
expiration_date=DateTime(2009, 12, 31), expiration_date=DateTime(2009, 12, 31),
version='001') version='001')
...@@ -1917,8 +1917,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase): ...@@ -1917,8 +1917,8 @@ class TestPayrollMixin(TestTradeModelLineMixin, ERP5ReportTestCase):
paysheet = self.portal.accounting_module.newContent( paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=model_1, specialise_value=model_1,
start_date=DateTime(2009, 07, 1), start_date=DateTime(2009, 7, 1),
stop_date=DateTime(2009, 07, 31), stop_date=DateTime(2009, 7, 31),
price_currency_value=eur) price_currency_value=eur)
specialise_value = paysheet.getSpecialiseValue() specialise_value = paysheet.getSpecialiseValue()
......
...@@ -46,7 +46,7 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase): ...@@ -46,7 +46,7 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase):
""" """
self.dsn_module = self.portal.getDefaultModuleValue("DSN Monthly Report") self.dsn_module = self.portal.getDefaultModuleValue("DSN Monthly Report")
self.setTimeZoneToUTC() self.setTimeZoneToUTC()
self.pinDateTime(DateTime(2015, 12, 01)) self.pinDateTime(DateTime(2015, 12, 1))
# Create the id_group 'dsn_event_counter' # Create the id_group 'dsn_event_counter'
self.portal.portal_ids.generateNewId(id_group='dsn_event_counter', id_generator='continuous_integer_increasing') self.portal.portal_ids.generateNewId(id_group='dsn_event_counter', id_generator='continuous_integer_increasing')
......
...@@ -281,16 +281,16 @@ class TestInvoice(TestInvoiceMixin): ...@@ -281,16 +281,16 @@ class TestInvoice(TestInvoiceMixin):
self.assertEqual(other_resource, self.assertEqual(other_resource,
invoice_movement.getResourceValue()) invoice_movement.getResourceValue())
order_line.setStartDate(DateTime(2001, 02, 03)) order_line.setStartDate(DateTime(2001, 2, 3))
self.tic() self.tic()
invoice_movement = invoice_applied_rule.contentValues()[0] invoice_movement = invoice_applied_rule.contentValues()[0]
self.assertEqual(DateTime(2001, 02, 03), self.assertEqual(DateTime(2001, 2, 3),
invoice_movement.getStartDate()) invoice_movement.getStartDate())
order_line.setStopDate(DateTime(2002, 03, 04)) order_line.setStopDate(DateTime(2002, 3, 4))
self.tic() self.tic()
invoice_movement = invoice_applied_rule.contentValues()[0] invoice_movement = invoice_applied_rule.contentValues()[0]
self.assertEqual(DateTime(2002, 03, 04), self.assertEqual(DateTime(2002, 3, 4),
invoice_movement.getStopDate()) invoice_movement.getStopDate())
@newSimulationExpectedFailure @newSimulationExpectedFailure
...@@ -478,20 +478,20 @@ class TestInvoice(TestInvoiceMixin): ...@@ -478,20 +478,20 @@ class TestInvoice(TestInvoiceMixin):
self.assertEqual(456, self.assertEqual(456,
invoice_transaction_movement.getQuantity()) invoice_transaction_movement.getQuantity())
order_line.setStartDate(DateTime(2001, 02, 03)) order_line.setStartDate(DateTime(2001, 2, 3))
self.tic() self.tic()
self.assertEqual(3, len(invoice_transaction_applied_rule)) self.assertEqual(3, len(invoice_transaction_applied_rule))
invoice_transaction_movement = getIncomeSimulationMovement( invoice_transaction_movement = getIncomeSimulationMovement(
invoice_transaction_applied_rule) invoice_transaction_applied_rule)
self.assertEqual(DateTime(2001, 02, 03), self.assertEqual(DateTime(2001, 2, 3),
invoice_transaction_movement.getStartDate()) invoice_transaction_movement.getStartDate())
order_line.setStopDate(DateTime(2002, 03, 04)) order_line.setStopDate(DateTime(2002, 3, 4))
self.tic() self.tic()
self.assertEqual(3, len(invoice_transaction_applied_rule)) self.assertEqual(3, len(invoice_transaction_applied_rule))
invoice_transaction_movement = getIncomeSimulationMovement( invoice_transaction_movement = getIncomeSimulationMovement(
invoice_transaction_applied_rule) invoice_transaction_applied_rule)
self.assertEqual(DateTime(2002, 03, 04), self.assertEqual(DateTime(2002, 3, 4),
invoice_transaction_movement.getStopDate()) invoice_transaction_movement.getStopDate())
def test_Invoice_viewAsODT(self): def test_Invoice_viewAsODT(self):
......
...@@ -162,10 +162,10 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -162,10 +162,10 @@ class TestApplyTradeCondition(TradeConditionTestCase):
def test_apply_trade_condition_with_payment_conditions(self): def test_apply_trade_condition_with_payment_conditions(self):
self.trade_condition.setPaymentConditionTradeDate('custom') self.trade_condition.setPaymentConditionTradeDate('custom')
self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01)) self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 1, 1))
self.order.setSpecialiseValue(self.trade_condition) self.order.setSpecialiseValue(self.trade_condition)
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
def test_apply_trade_condition_with_payment_conditions_with_hierarchy(self): def test_apply_trade_condition_with_payment_conditions_with_hierarchy(self):
...@@ -174,12 +174,12 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -174,12 +174,12 @@ class TestApplyTradeCondition(TradeConditionTestCase):
title='Other Trade Condition') title='Other Trade Condition')
other_trade_condition.setPaymentConditionTradeDate('custom') other_trade_condition.setPaymentConditionTradeDate('custom')
other_trade_condition.setPaymentConditionPaymentDate( other_trade_condition.setPaymentConditionPaymentDate(
DateTime(2001, 01, 01)) DateTime(2001, 1, 1))
self.trade_condition.setSpecialiseValue(other_trade_condition) self.trade_condition.setSpecialiseValue(other_trade_condition)
self.order.setSpecialiseValue(self.trade_condition) self.order.setSpecialiseValue(self.trade_condition)
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
def test_apply_trade_condition_twice_update_order(self): def test_apply_trade_condition_twice_update_order(self):
...@@ -189,7 +189,7 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -189,7 +189,7 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.trade_condition.setDestinationValue(self.client) self.trade_condition.setDestinationValue(self.client)
self.trade_condition.setPriceCurrencyValue(self.currency) self.trade_condition.setPriceCurrencyValue(self.currency)
self.trade_condition.setPaymentConditionTradeDate('custom') self.trade_condition.setPaymentConditionTradeDate('custom')
self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 01, 01)) self.trade_condition.setPaymentConditionPaymentDate(DateTime(2001, 1, 1))
self.order.setSpecialiseValue(self.trade_condition) self.order.setSpecialiseValue(self.trade_condition)
self.order.Order_applyTradeCondition(self.trade_condition, force=1) self.order.Order_applyTradeCondition(self.trade_condition, force=1)
...@@ -201,7 +201,7 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -201,7 +201,7 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationValue()) self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue()) self.assertEqual(self.currency, self.order.getPriceCurrencyValue())
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2001, 01, 01), self.assertEqual(DateTime(2001, 1, 1),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
new_vendor = self.portal.organisation_module.newContent( new_vendor = self.portal.organisation_module.newContent(
...@@ -221,7 +221,7 @@ class TestApplyTradeCondition(TradeConditionTestCase): ...@@ -221,7 +221,7 @@ class TestApplyTradeCondition(TradeConditionTestCase):
self.assertEqual(self.client, self.order.getDestinationValue()) self.assertEqual(self.client, self.order.getDestinationValue())
self.assertEqual(self.currency, self.order.getPriceCurrencyValue()) self.assertEqual(self.currency, self.order.getPriceCurrencyValue())
self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date')) self.assertEqual('custom', self.order.asComposedDocument().getProperty('payment_condition_trade_date'))
self.assertEqual(DateTime(2002, 02, 02), self.assertEqual(DateTime(2002, 2, 2),
self.order.asComposedDocument().getProperty('payment_condition_payment_date')) self.order.asComposedDocument().getProperty('payment_condition_payment_date'))
......
...@@ -61,7 +61,7 @@ class ERP5NodeConduit(TioSafeBaseConduit): ...@@ -61,7 +61,7 @@ class ERP5NodeConduit(TioSafeBaseConduit):
destination=object.getRelativeUrl(), destination=object.getRelativeUrl(),
destination_decision=object.getRelativeUrl(), destination_decision=object.getRelativeUrl(),
destination_administration=object.getRelativeUrl(), destination_administration=object.getRelativeUrl(),
version=001) version=0o01)
  • I think this should be either "001" or 1.

  • oh, yes it should have been "001", version property is a string. I'm re-reading the patch to see if there are other "versions" cases. Thanks !

  • ( and I think it would be interesting to run an ERP5 test suite with setters running in a kind of "strict-mode" -ie not silently converting things and hiding this kind of errors )

Please register or sign in to reply
stc.validate() stc.validate()
def _updateSaleTradeCondition(self, object, **kw): # pylint: disable=redefined-builtin def _updateSaleTradeCondition(self, object, **kw): # pylint: disable=redefined-builtin
......
...@@ -78,7 +78,7 @@ class ERP5PaymentTransactionConduit(TioSafeBaseConduit): ...@@ -78,7 +78,7 @@ class ERP5PaymentTransactionConduit(TioSafeBaseConduit):
# Create the STC # Create the STC
stc = object.getPortalObject().sale_trade_condition_module.newContent(title=stc_title, stc = object.getPortalObject().sale_trade_condition_module.newContent(title=stc_title,
specialise=default_stc, specialise=default_stc,
version=001) version=0o01)
Please register or sign in to reply
stc.validate() stc.validate()
return stc return stc
......
...@@ -627,7 +627,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -627,7 +627,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
specialise=self.business_process, specialise=self.business_process,
source_value = from_organisation, source_value = from_organisation,
destination_value = organisation, destination_value = organisation,
start_date=DateTime(2019, 02, 20), start_date=DateTime(2019, 2, 20),
) )
resource_value = sequence.get('resource') resource_value = sequence.get('resource')
delivery.newContent( portal_type='Internal Packing List Line', delivery.newContent( portal_type='Internal Packing List Line',
...@@ -649,7 +649,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -649,7 +649,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
self.assertEqual(2, getInventoryQuantity()) self.assertEqual(2, getInventoryQuantity())
inventory = self.getInventoryModule().newContent() inventory = self.getInventoryModule().newContent()
inventory.edit(start_date=DateTime(2019, 02, 21), inventory.edit(start_date=DateTime(2019, 2, 21),
destination_value=organisation, destination_value=organisation,
full_inventory=True) full_inventory=True)
inventory.deliver() inventory.deliver()
...@@ -694,7 +694,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase): ...@@ -694,7 +694,7 @@ class TestInventoryModule(TestOrderMixin, ERP5TypeTestCase):
self.assertEqual(2, getInventoryQuantity()) self.assertEqual(2, getInventoryQuantity())
inventory = self.getInventoryModule().newContent() inventory = self.getInventoryModule().newContent()
inventory.edit(start_date=DateTime(2019, 02, 21), inventory.edit(start_date=DateTime(2019, 2, 21),
destination_value=organisation, destination_value=organisation,
full_inventory=True) full_inventory=True)
inventory_line = inventory.newContent(portal_type='Inventory Line', inventory_line = inventory.newContent(portal_type='Inventory Line',
......
...@@ -125,7 +125,7 @@ class FTPConnector(XMLObject): ...@@ -125,7 +125,7 @@ class FTPConnector(XMLObject):
finally: finally:
conn.logout() conn.logout()
def createDirectory(self, path, mode=0777): def createDirectory(self, path, mode=0o777):
"""Create a directory `path`, with file mode `mode`. """Create a directory `path`, with file mode `mode`.
The directory is created immediatly, even if transaction is aborted. The directory is created immediatly, even if transaction is aborted.
......
...@@ -171,7 +171,7 @@ class SFTPConnection: ...@@ -171,7 +171,7 @@ class SFTPConnection:
raise SFTPError('%s while trying to rename "%s" to "%s" on %s.' % \ raise SFTPError('%s while trying to rename "%s" to "%s" on %s.' % \
(str(msg), old_path, new_path, self.url)) (str(msg), old_path, new_path, self.url))
def createDirectory(self, path, mode=0777): def createDirectory(self, path, mode=0o777):
"""Create a directory `path` with mode `mode`. """Create a directory `path` with mode `mode`.
""" """
return self.conn.mkdir(path, mode) return self.conn.mkdir(path, mode)
......
...@@ -1960,94 +1960,94 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -1960,94 +1960,94 @@ class TestMovementHistoryList(InventoryAPITestCase):
def test_FromDate(self): def test_FromDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# from_date takes all movements >= # from_date takes all movements >=
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 03), from_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
section_uid=self.mirror_section.getUid())), 2) section_uid=self.mirror_section.getUid())), 2)
def test_AtDate(self): def test_AtDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# at_date takes all movements <= # at_date takes all movements <=
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
at_date=DateTime(2006, 01, 02), at_date=DateTime(2006, 1, 2),
section_uid=self.mirror_section.getUid())), 2) section_uid=self.mirror_section.getUid())), 2)
def test_ToDate(self): def test_ToDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# to_date takes all movements < # to_date takes all movements <
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 1) section_uid=self.section.getUid())), 1)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
to_date=DateTime(2006, 01, 02), to_date=DateTime(2006, 1, 2),
section_uid=self.mirror_section.getUid())), 1) section_uid=self.mirror_section.getUid())), 1)
def test_FromDateAtDate(self): def test_FromDateAtDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# both from_date and at_date # both from_date and at_date
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 03), from_date=DateTime(2006, 1, 3),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 1) section_uid=self.section.getUid())), 1)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2005, 01, 02), from_date=DateTime(2005, 1, 2),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 2) section_uid=self.section.getUid())), 2)
# from other side # from other side
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
at_date=DateTime(2006, 01, 03), at_date=DateTime(2006, 1, 3),
section_uid=self.mirror_section.getUid())), 2) section_uid=self.mirror_section.getUid())), 2)
def test_FromDateToDate(self): def test_FromDateToDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
for date in [DateTime(2006, 01, day) for day in range(1, 4)]: for date in [DateTime(2006, 1, day) for day in range(1, 4)]:
self._makeMovement(quantity=100, self._makeMovement(quantity=100,
start_date=date, start_date=date,
stop_date=date+1) stop_date=date+1)
# both from_date and to_date # both from_date and to_date
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 03), from_date=DateTime(2006, 1, 3),
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 0) section_uid=self.section.getUid())), 0)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.section.getUid())), 1) section_uid=self.section.getUid())), 1)
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2005, 01, 02), from_date=DateTime(2005, 1, 2),
to_date=DateTime(2007, 01, 02), to_date=DateTime(2007, 1, 2),
section_uid=self.section.getUid())), 3) section_uid=self.section.getUid())), 3)
# from other side # from other side
self.assertEqual(len(getMovementHistoryList( self.assertEqual(len(getMovementHistoryList(
from_date=DateTime(2006, 01, 02), from_date=DateTime(2006, 1, 2),
to_date=DateTime(2006, 01, 03), to_date=DateTime(2006, 1, 3),
section_uid=self.mirror_section.getUid())), 1) section_uid=self.mirror_section.getUid())), 1)
...@@ -2085,7 +2085,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2085,7 +2085,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
def test_SortOnDate(self): def test_SortOnDate(self):
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_list = [DateTime(2006, 01, day) for day in range(1, 10)] date_list = [DateTime(2006, 1, day) for day in range(1, 10)]
reverse_date_list = date_list[:] reverse_date_list = date_list[:]
reverse_date_list.reverse() reverse_date_list.reverse()
...@@ -2194,7 +2194,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2194,7 +2194,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
"""Test that a running_total_quantity attribute is set on brains """Test that a running_total_quantity attribute is set on brains
""" """
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_and_qty_list = [(DateTime(2006, 01, day), day) for day in range(1, 10)] date_and_qty_list = [(DateTime(2006, 1, day), day) for day in range(1, 10)]
for date, quantity in date_and_qty_list: for date, quantity in date_and_qty_list:
self._makeMovement(stop_date=date, quantity=quantity) self._makeMovement(stop_date=date, quantity=quantity)
movement_history_list = getMovementHistoryList( movement_history_list = getMovementHistoryList(
...@@ -2213,7 +2213,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2213,7 +2213,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
"""Test that a running_total_price attribute is set on brains """Test that a running_total_price attribute is set on brains
""" """
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_and_price_list = [(DateTime(2006, 01, day), day) for day in range(1, 10)] date_and_price_list = [(DateTime(2006, 1, day), day) for day in range(1, 10)]
for date, price in date_and_price_list: for date, price in date_and_price_list:
self._makeMovement(stop_date=date, quantity=1, price=price) self._makeMovement(stop_date=date, quantity=1, price=price)
movement_history_list = getMovementHistoryList( movement_history_list = getMovementHistoryList(
...@@ -2233,7 +2233,7 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -2233,7 +2233,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
value. value.
""" """
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
date_and_qty_list = [(DateTime(2006, 01, day), day) for day in range(1, 10)] date_and_qty_list = [(DateTime(2006, 1, day), day) for day in range(1, 10)]
for date, quantity in date_and_qty_list: for date, quantity in date_and_qty_list:
self._makeMovement(stop_date=date, price=quantity, quantity=quantity) self._makeMovement(stop_date=date, price=quantity, quantity=quantity)
initial_running_total_price=100 initial_running_total_price=100
......
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