summaryrefslogtreecommitdiff
path: root/addons/account_edi_facturx
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2020-07-08 12:36:17 +0000
committerChristophe Monniez <moc@odoo.com>2020-07-10 08:20:13 +0000
commit92a7f8c13fa6bc84a66f973f9454971d346fd801 (patch)
tree97a19b6bd49bd7b288bb9356d90c717c52ee4eb8 /addons/account_edi_facturx
parentda6c9027f4df6ca98420ffafcf32e37dc916d374 (diff)
[IMP] base, tests: use freezegun lib to mock dates and datetimes
closes odoo/odoo#54227 Related: odoo/enterprise#11742 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Diffstat (limited to 'addons/account_edi_facturx')
-rw-r--r--addons/account_edi_facturx/tests/test_facturx.py122
1 files changed, 62 insertions, 60 deletions
diff --git a/addons/account_edi_facturx/tests/test_facturx.py b/addons/account_edi_facturx/tests/test_facturx.py
index 98a0f056ef5..faf1e89c38e 100644
--- a/addons/account_edi_facturx/tests/test_facturx.py
+++ b/addons/account_edi_facturx/tests/test_facturx.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+from freezegun import freeze_time
+
from odoo.addons.account.tests.account_test_xml import AccountTestEdiCommon
from odoo.tests import tagged
@@ -151,74 +153,74 @@ class TestAccountEdiFacturx(AccountTestEdiCommon):
</CrossIndustryInvoice>
'''
+ @freeze_time('2017-02-01')
def test_facturx(self):
''' Test the generated Facturx Edi attachment without any modification of the invoice. '''
- with self.mocked_today('2017-02-01'):
- self.invoice.post()
+ self.invoice.post()
- xml_content = self.facturx_edi_format._export_invoice_to_attachment(self.invoice)['datas']
- current_etree = self.get_xml_tree_from_string(xml_content)
- expected_etree = self.get_xml_tree_from_string(self.expected_invoice_facturx_values)
- self.assertXmlTreeEqual(current_etree, expected_etree)
+ xml_content = self.facturx_edi_format._export_invoice_to_attachment(self.invoice)['datas']
+ current_etree = self.get_xml_tree_from_string(xml_content)
+ expected_etree = self.get_xml_tree_from_string(self.expected_invoice_facturx_values)
+ self.assertXmlTreeEqual(current_etree, expected_etree)
+ @freeze_time('2017-02-01')
def test_facturx_group_of_taxes(self):
''' Same as above with a group of taxes. '''
self.invoice.write({
'invoice_line_ids': [(1, self.invoice.invoice_line_ids.id, {'tax_ids': [(6, 0, self.tax_group.ids)]})],
})
- with self.mocked_today('2017-02-01'):
- self.invoice.post()
-
- xml_content = self.facturx_edi_format._export_invoice_to_attachment(self.invoice)['datas']
- current_etree = self.get_xml_tree_from_string(xml_content)
- expected_etree = self.with_applied_xpath(
- self.get_xml_tree_from_string(self.expected_invoice_facturx_values),
- '''
- <xpath expr="//GrossPriceProductTradePrice/ChargeAmount" position="replace">
- <ChargeAmount currencyID="Gol">275.000</ChargeAmount>
- </xpath>
- <xpath expr="//SpecifiedLineTradeSettlement" position="replace">
- <SpecifiedLineTradeSettlement>
- <ApplicableTradeTax>
- <RateApplicablePercent>10.0</RateApplicablePercent>
- </ApplicableTradeTax>
- <ApplicableTradeTax>
- <RateApplicablePercent>20.0</RateApplicablePercent>
- </ApplicableTradeTax>
- <SpecifiedTradeSettlementLineMonetarySummation>
- <LineTotalAmount currencyID="Gol">1000.000</LineTotalAmount>
- </SpecifiedTradeSettlementLineMonetarySummation>
- </SpecifiedLineTradeSettlement>
- </xpath>
- <xpath expr="//ApplicableHeaderTradeSettlement" position="replace">
- <ApplicableHeaderTradeSettlement>
- <ApplicableTradeTax>
- <CalculatedAmount currencyID="Gol">220.000</CalculatedAmount>
- <BasisAmount currencyID="Gol">1100.000</BasisAmount>
- <RateApplicablePercent>20.0</RateApplicablePercent>
- </ApplicableTradeTax>
- <ApplicableTradeTax>
- <CalculatedAmount currencyID="Gol">100.000</CalculatedAmount>
- <BasisAmount currencyID="Gol">1000.000</BasisAmount>
- <RateApplicablePercent>10.0</RateApplicablePercent>
- </ApplicableTradeTax>
- <SpecifiedTradePaymentTerms>
- <DueDateDateTime>
- <DateTimeString>20170101</DateTimeString>
- </DueDateDateTime>
- </SpecifiedTradePaymentTerms>
- <SpecifiedTradeSettlementHeaderMonetarySummation>
- <LineTotalAmount currencyID="Gol">1000.000</LineTotalAmount>
- <TaxBasisTotalAmount currencyID="Gol">1000.000</TaxBasisTotalAmount>
- <TaxTotalAmount currencyID="Gol">320.000</TaxTotalAmount>
- <GrandTotalAmount currencyID="Gol">1320.000</GrandTotalAmount>
- <TotalPrepaidAmount currencyID="Gol">0.000</TotalPrepaidAmount>
- <DuePayableAmount currencyID="Gol">1320.000</DuePayableAmount>
- </SpecifiedTradeSettlementHeaderMonetarySummation>
- </ApplicableHeaderTradeSettlement>
- </xpath>
- ''',
- )
- self.assertXmlTreeEqual(current_etree, expected_etree)
+ self.invoice.post()
+
+ xml_content = self.facturx_edi_format._export_invoice_to_attachment(self.invoice)['datas']
+ current_etree = self.get_xml_tree_from_string(xml_content)
+ expected_etree = self.with_applied_xpath(
+ self.get_xml_tree_from_string(self.expected_invoice_facturx_values),
+ '''
+ <xpath expr="//GrossPriceProductTradePrice/ChargeAmount" position="replace">
+ <ChargeAmount currencyID="Gol">275.000</ChargeAmount>
+ </xpath>
+ <xpath expr="//SpecifiedLineTradeSettlement" position="replace">
+ <SpecifiedLineTradeSettlement>
+ <ApplicableTradeTax>
+ <RateApplicablePercent>10.0</RateApplicablePercent>
+ </ApplicableTradeTax>
+ <ApplicableTradeTax>
+ <RateApplicablePercent>20.0</RateApplicablePercent>
+ </ApplicableTradeTax>
+ <SpecifiedTradeSettlementLineMonetarySummation>
+ <LineTotalAmount currencyID="Gol">1000.000</LineTotalAmount>
+ </SpecifiedTradeSettlementLineMonetarySummation>
+ </SpecifiedLineTradeSettlement>
+ </xpath>
+ <xpath expr="//ApplicableHeaderTradeSettlement" position="replace">
+ <ApplicableHeaderTradeSettlement>
+ <ApplicableTradeTax>
+ <CalculatedAmount currencyID="Gol">220.000</CalculatedAmount>
+ <BasisAmount currencyID="Gol">1100.000</BasisAmount>
+ <RateApplicablePercent>20.0</RateApplicablePercent>
+ </ApplicableTradeTax>
+ <ApplicableTradeTax>
+ <CalculatedAmount currencyID="Gol">100.000</CalculatedAmount>
+ <BasisAmount currencyID="Gol">1000.000</BasisAmount>
+ <RateApplicablePercent>10.0</RateApplicablePercent>
+ </ApplicableTradeTax>
+ <SpecifiedTradePaymentTerms>
+ <DueDateDateTime>
+ <DateTimeString>20170101</DateTimeString>
+ </DueDateDateTime>
+ </SpecifiedTradePaymentTerms>
+ <SpecifiedTradeSettlementHeaderMonetarySummation>
+ <LineTotalAmount currencyID="Gol">1000.000</LineTotalAmount>
+ <TaxBasisTotalAmount currencyID="Gol">1000.000</TaxBasisTotalAmount>
+ <TaxTotalAmount currencyID="Gol">320.000</TaxTotalAmount>
+ <GrandTotalAmount currencyID="Gol">1320.000</GrandTotalAmount>
+ <TotalPrepaidAmount currencyID="Gol">0.000</TotalPrepaidAmount>
+ <DuePayableAmount currencyID="Gol">1320.000</DuePayableAmount>
+ </SpecifiedTradeSettlementHeaderMonetarySummation>
+ </ApplicableHeaderTradeSettlement>
+ </xpath>
+ ''',
+ )
+ self.assertXmlTreeEqual(current_etree, expected_etree)