From b7577f1b7dee6bf476d96615a1476c87314428ef Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 4 May 2020 18:24:58 +0200 Subject: [PATCH] Add a test to check that participants are ordered consistently in statistics page --- ihatemoney/tests/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py index 911724f0..b13c7c07 100644 --- a/ihatemoney/tests/tests.py +++ b/ihatemoney/tests/tests.py @@ -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"{}".format(name) for name in order + ) + regex2 = r".*".join( + r"{}".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")