Add a test to check that participants are ordered consistently in statistics page

This commit is contained in:
Baptiste Jonglez 2020-05-04 18:24:58 +02:00
parent 99fd1785e5
commit b7577f1b7d

View file

@ -4,6 +4,7 @@ import datetime
import io
import json
import os
import re
from time import sleep
import unittest
from unittest.mock import MagicMock, patch
@ -953,6 +954,20 @@ class BudgetTestCase(IhatemoneyTestCase):
response.data.decode("utf-8"), regex.format("pépé", "0.00", "0.00"),
)
# Check that the order of participants in the sidebar table is the
# same as in the main table.
order = ["fred", "pépé", "tata", "zorglub"]
regex1 = r".*".join(
r"<td class=\"balance-name\">{}</td>".format(name) for name in order
)
regex2 = r".*".join(
r"<td class=\"d-md-none\">{}</td>".format(name) for name in order
)
# Build the regexp ourselves to be able to pass the DOTALL flag
# (so that ".*" matches newlines)
self.assertRegex(response.data.decode("utf-8"), re.compile(regex1, re.DOTALL))
self.assertRegex(response.data.decode("utf-8"), re.compile(regex2, re.DOTALL))
def test_settle_page(self):
self.post_project("raclette")
response = self.client.get("/raclette/settle_bills")