Fix tests

This commit is contained in:
Ludovic Stephan 2020-03-09 17:00:56 +01:00
parent f10d6d1a71
commit c9dad9465a

View file

@ -628,37 +628,51 @@ class AccountStatOperationListViewTests(ViewTestCaseMixin, TestCase):
expected_stats = [ expected_stats = [
{ {
"label": "Derniers mois", "label": "Tout le temps",
"url": { "url": {
"path": base_url, "path": base_url,
"query": { "query": {
"scale_n_steps": ["7"], "types": ["['purchase']"],
"scale_name": ["month"], "scale_name": ["month"],
"scale_last": ["True"],
"scale_begin": [
self.accounts["user1"].created_at.isoformat(" ")
],
},
},
},
{
"label": "1 an",
"url": {
"path": base_url,
"query": {
"types": ["['purchase']"], "types": ["['purchase']"],
"scale_n_steps": ["12"],
"scale_name": ["month"],
"scale_last": ["True"], "scale_last": ["True"],
}, },
}, },
}, },
{ {
"label": "Dernières semaines", "label": "3 mois",
"url": { "url": {
"path": base_url, "path": base_url,
"query": { "query": {
"scale_n_steps": ["7"], "types": ["['purchase']"],
"scale_n_steps": ["13"],
"scale_name": ["week"], "scale_name": ["week"],
"types": ["['purchase']"],
"scale_last": ["True"], "scale_last": ["True"],
}, },
}, },
}, },
{ {
"label": "Derniers jours", "label": "2 semaines",
"url": { "url": {
"path": base_url, "path": base_url,
"query": { "query": {
"scale_n_steps": ["7"],
"scale_name": ["day"],
"types": ["['purchase']"], "types": ["['purchase']"],
"scale_n_steps": ["14"],
"scale_name": ["day"],
"scale_last": ["True"], "scale_last": ["True"],
}, },
}, },
@ -1524,6 +1538,21 @@ class ArticleStatSalesListViewTests(ViewTestCaseMixin, TestCase):
self.article = Article.objects.create( self.article = Article.objects.create(
name="Article", category=ArticleCategory.objects.create(name="Category") 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): def test_ok(self):
r = self.client.get(self.url) r = self.client.get(self.url)
@ -1535,33 +1564,44 @@ class ArticleStatSalesListViewTests(ViewTestCaseMixin, TestCase):
expected_stats = [ expected_stats = [
{ {
"label": "Derniers mois", "label": "Tout le temps",
"url": { "url": {
"path": base_url, "path": base_url,
"query": { "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_name": ["month"],
"scale_last": ["True"], "scale_last": ["True"],
}, },
}, },
}, },
{ {
"label": "Dernières semaines", "label": "3 mois",
"url": { "url": {
"path": base_url, "path": base_url,
"query": { "query": {
"scale_n_steps": ["7"], "scale_n_steps": ["13"],
"scale_name": ["week"], "scale_name": ["week"],
"scale_last": ["True"], "scale_last": ["True"],
}, },
}, },
}, },
{ {
"label": "Derniers jours", "label": "2 semaines",
"url": { "url": {
"path": base_url, "path": base_url,
"query": { "query": {
"scale_n_steps": ["7"], "scale_n_steps": ["14"],
"scale_name": ["day"], "scale_name": ["day"],
"scale_last": ["True"], "scale_last": ["True"],
}, },