From c9dad9465a5eea0408fd37d1499114a2502dcb44 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 9 Mar 2020 17:00:56 +0100 Subject: [PATCH] Fix tests --- kfet/tests/test_views.py | 68 +++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/kfet/tests/test_views.py b/kfet/tests/test_views.py index 08d2cb32..bcd9a9b4 100644 --- a/kfet/tests/test_views.py +++ b/kfet/tests/test_views.py @@ -628,37 +628,51 @@ class AccountStatOperationListViewTests(ViewTestCaseMixin, TestCase): expected_stats = [ { - "label": "Derniers mois", + "label": "Tout le temps", "url": { "path": base_url, "query": { - "scale_n_steps": ["7"], + "types": ["['purchase']"], "scale_name": ["month"], + "scale_last": ["True"], + "scale_begin": [ + self.accounts["user1"].created_at.isoformat(" ") + ], + }, + }, + }, + { + "label": "1 an", + "url": { + "path": base_url, + "query": { "types": ["['purchase']"], + "scale_n_steps": ["12"], + "scale_name": ["month"], "scale_last": ["True"], }, }, }, { - "label": "Dernières semaines", + "label": "3 mois", "url": { "path": base_url, "query": { - "scale_n_steps": ["7"], + "types": ["['purchase']"], + "scale_n_steps": ["13"], "scale_name": ["week"], - "types": ["['purchase']"], "scale_last": ["True"], }, }, }, { - "label": "Derniers jours", + "label": "2 semaines", "url": { "path": base_url, "query": { - "scale_n_steps": ["7"], - "scale_name": ["day"], "types": ["['purchase']"], + "scale_n_steps": ["14"], + "scale_name": ["day"], "scale_last": ["True"], }, }, @@ -1524,6 +1538,21 @@ class ArticleStatSalesListViewTests(ViewTestCaseMixin, TestCase): self.article = Article.objects.create( name="Article", category=ArticleCategory.objects.create(name="Category") ) + checkout = Checkout.objects.create( + name="Checkout", + created_by=self.accounts["team"], + balance=5, + valid_from=self.now, + valid_to=self.now + timedelta(days=5), + ) + + self.opegroup = create_operation_group( + on_acc=self.accounts["user"], + checkout=checkout, + content=[ + {"type": Operation.PURCHASE, "article": self.article, "article_nb": 2}, + ], + ) def test_ok(self): r = self.client.get(self.url) @@ -1535,33 +1564,44 @@ class ArticleStatSalesListViewTests(ViewTestCaseMixin, TestCase): expected_stats = [ { - "label": "Derniers mois", + "label": "Tout le temps", "url": { "path": base_url, "query": { - "scale_n_steps": ["7"], + "scale_name": ["month"], + "scale_last": ["True"], + "scale_begin": [self.opegroup.at.isoformat(" ")], + }, + }, + }, + { + "label": "1 an", + "url": { + "path": base_url, + "query": { + "scale_n_steps": ["12"], "scale_name": ["month"], "scale_last": ["True"], }, }, }, { - "label": "Dernières semaines", + "label": "3 mois", "url": { "path": base_url, "query": { - "scale_n_steps": ["7"], + "scale_n_steps": ["13"], "scale_name": ["week"], "scale_last": ["True"], }, }, }, { - "label": "Derniers jours", + "label": "2 semaines", "url": { "path": base_url, "query": { - "scale_n_steps": ["7"], + "scale_n_steps": ["14"], "scale_name": ["day"], "scale_last": ["True"], },