From cd2d3ee6b4a1647ad0a1568546656eec3f77540f Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Sun, 6 Oct 2019 17:44:30 +0200 Subject: [PATCH] django2.2: fix tests for accounting --- .../journal_statement_accounting.jinja | 6 +-- .../accounting/journal_statement_nature.jinja | 10 ++-- .../accounting/journal_statement_person.jinja | 8 ++-- accounting/tests.py | 46 +++++++++++++------ 4 files changed, 45 insertions(+), 25 deletions(-) diff --git a/accounting/templates/accounting/journal_statement_accounting.jinja b/accounting/templates/accounting/journal_statement_accounting.jinja index 98564095..0661bbcf 100644 --- a/accounting/templates/accounting/journal_statement_accounting.jinja +++ b/accounting/templates/accounting/journal_statement_accounting.jinja @@ -20,14 +20,14 @@ {% for k,v in statement.items() %} {{ k }} - {{ v }} + {{ "%.2f" % v }} {% endfor %} -

{% trans %}Amount: {% endtrans %}{{ object.amount }} €

-

{% trans %}Effective amount: {% endtrans %}{{ object.effective_amount }} €

+

{% trans %}Amount: {% endtrans %}{{ "%.2f" % object.amount }} €

+

{% trans %}Effective amount: {% endtrans %}{{ "%.2f" %object.effective_amount }} €

{% endblock %} diff --git a/accounting/templates/accounting/journal_statement_nature.jinja b/accounting/templates/accounting/journal_statement_nature.jinja index 0bfca0d0..a3aa1567 100644 --- a/accounting/templates/accounting/journal_statement_nature.jinja +++ b/accounting/templates/accounting/journal_statement_nature.jinja @@ -18,12 +18,12 @@ {% for k,v in dict['CREDIT'].items() %} {{ k }} - {{ v }} + {{ "%.2f" % v }} {% endfor %} - {% trans %}Total: {% endtrans %}{{ dict['CREDIT_sum'] }} + {% trans %}Total: {% endtrans %}{{ "%.2f" % dict['CREDIT_sum'] }}
{% trans %}Debit{% endtrans %}
@@ -37,19 +37,19 @@ {% for k,v in dict['DEBIT'].items() %} - + {% endfor %}
{{ k }}{{ v }}{{ "%.2f" % v }}
- {% trans %}Total: {% endtrans %}{{ dict['DEBIT_sum'] }} + {% trans %}Total: {% endtrans %}{{ "%.2f" % dict['DEBIT_sum'] }} {% endmacro %} {% block content %}

{% trans %}Statement by nature: {% endtrans %} {{ object.name }}

{% for k,v in statement.items() %} -

{{ k }} : {{ v['CREDIT_sum'] - v['DEBIT_sum'] }}

+

{{ k }} : {{ "%.2f" % (v['CREDIT_sum'] - v['DEBIT_sum']) }}

{{ display_tables(v) }}
{% endfor %} diff --git a/accounting/templates/accounting/journal_statement_person.jinja b/accounting/templates/accounting/journal_statement_person.jinja index 0fd0dd5d..9a88e73f 100644 --- a/accounting/templates/accounting/journal_statement_person.jinja +++ b/accounting/templates/accounting/journal_statement_person.jinja @@ -28,14 +28,14 @@ {% else %} {% endif %} - {{ credit_statement[key] }} + {{ "%.2f" % credit_statement[key] }} {% endfor %} -

Total : {{ total_credit }}

+

Total : {{ "%.2f" % total_credit }}

{% trans %}Debit{% endtrans %}

@@ -56,13 +56,13 @@ {% else %} {% endif %} - {{ debit_statement[key] }} + {{ "%.2f" % debit_statement[key] }} {% endfor %} -

Total : {{ total_debit }}

+

Total : {{ "%.2f" % total_debit }}

{% endblock %} diff --git a/accounting/tests.py b/accounting/tests.py index 96b19010..f424d8e8 100644 --- a/accounting/tests.py +++ b/accounting/tests.py @@ -272,30 +272,50 @@ class OperationTest(TestCase): def test_nature_statement(self): self.client.login(username="comptable", password="plop") - response_get = self.client.get( + response = self.client.get( reverse("accounting:journal_nature_statement", args=[self.journal.id]) ) - self.assertTrue( - "bob (Troll Pench\\xc3\\xa9) : 3.00" in str(response_get.content) - ) + self.assertContains(response, "bob (Troll Penché) : 3.00", status_code=200) def test_person_statement(self): self.client.login(username="comptable", password="plop") - response_get = self.client.get( + response = self.client.get( reverse("accounting:journal_person_statement", args=[self.journal.id]) ) - self.assertTrue( - "3.00" in str(response_get.content) - and 'S' Kia' - in str(response_get.content) + self.assertContains(response, "Total : 5575.72", status_code=200) + self.assertContains(response, "Total : 71.42") + self.assertContains( + response, + """ + S' Kia + + 3.00""", + ) + self.assertContains( + response, + """ + S' Kia + + 823.00""", ) def test_accounting_statement(self): self.client.login(username="comptable", password="plop") - response_get = self.client.get( + response = self.client.get( reverse("accounting:journal_accounting_statement", args=[self.journal.id]) ) - self.assertTrue( - "443 - Cr\\xc3\\xa9dit - Ce code n'existe pas" - in str(response_get.content) + self.assertContains( + response, + """ + + 443 - Crédit - Ce code n'existe pas + 3.00 + """, + status_code=200, + ) + self.assertContains( + response, + """ +

Montant : -5504.30 €

+

Montant effectif: -5504.30 €

""", )