Fix tests 3
This commit is contained in:
parent
7438445110
commit
fb4455af39
1 changed files with 105 additions and 80 deletions
|
@ -3358,7 +3358,26 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
json_data, {"canceled": [operation.pk], "errors": {}, "warnings": {}}
|
json_data,
|
||||||
|
{
|
||||||
|
"canceled": [
|
||||||
|
{
|
||||||
|
"id": operation.id,
|
||||||
|
# l'encodage des dates en JSON est relou...
|
||||||
|
"canceled_at": mock.ANY,
|
||||||
|
"canceled_by__trigramme": None,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"errors": {},
|
||||||
|
"warnings": {},
|
||||||
|
"opegroups_to_update": [
|
||||||
|
{
|
||||||
|
"id": group.pk,
|
||||||
|
"amount": str(group.amount),
|
||||||
|
"is_cof": group.is_cof,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.account.refresh_from_db()
|
self.account.refresh_from_db()
|
||||||
|
@ -3370,26 +3389,7 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
|
|
||||||
self.kpsul_consumer_mock.group_send.assert_called_with(
|
self.kpsul_consumer_mock.group_send.assert_called_with(
|
||||||
"kfet.kpsul",
|
"kfet.kpsul",
|
||||||
{
|
{"checkouts": [], "articles": [{"id": self.article.pk, "stock": 22}]},
|
||||||
"opegroups": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": group.pk,
|
|
||||||
"amount": Decimal("0.00"),
|
|
||||||
"is_cof": False,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"opes": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": operation.pk,
|
|
||||||
"canceled_by__trigramme": None,
|
|
||||||
"canceled_at": self.now + timedelta(seconds=15),
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"checkouts": [],
|
|
||||||
"articles": [{"id": self.article.pk, "stock": 22}],
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_purchase_with_addcost(self):
|
def test_purchase_with_addcost(self):
|
||||||
|
@ -3546,7 +3546,26 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
json_data, {"canceled": [operation.pk], "errors": {}, "warnings": {}}
|
json_data,
|
||||||
|
{
|
||||||
|
"canceled": [
|
||||||
|
{
|
||||||
|
"id": operation.id,
|
||||||
|
# l'encodage des dates en JSON est relou...
|
||||||
|
"canceled_at": mock.ANY,
|
||||||
|
"canceled_by__trigramme": None,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"errors": {},
|
||||||
|
"warnings": {},
|
||||||
|
"opegroups_to_update": [
|
||||||
|
{
|
||||||
|
"id": group.pk,
|
||||||
|
"amount": str(group.amount),
|
||||||
|
"is_cof": group.is_cof,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.account.refresh_from_db()
|
self.account.refresh_from_db()
|
||||||
|
@ -3559,22 +3578,6 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
self.kpsul_consumer_mock.group_send.assert_called_with(
|
self.kpsul_consumer_mock.group_send.assert_called_with(
|
||||||
"kfet.kpsul",
|
"kfet.kpsul",
|
||||||
{
|
{
|
||||||
"opegroups": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": group.pk,
|
|
||||||
"amount": Decimal("0.00"),
|
|
||||||
"is_cof": False,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"opes": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": operation.pk,
|
|
||||||
"canceled_by__trigramme": None,
|
|
||||||
"canceled_at": self.now + timedelta(seconds=15),
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"checkouts": [{"id": self.checkout.pk, "balance": Decimal("89.25")}],
|
"checkouts": [{"id": self.checkout.pk, "balance": Decimal("89.25")}],
|
||||||
"articles": [],
|
"articles": [],
|
||||||
},
|
},
|
||||||
|
@ -3630,7 +3633,26 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
json_data, {"canceled": [operation.pk], "errors": {}, "warnings": {}}
|
json_data,
|
||||||
|
{
|
||||||
|
"canceled": [
|
||||||
|
{
|
||||||
|
"id": operation.id,
|
||||||
|
# l'encodage des dates en JSON est relou...
|
||||||
|
"canceled_at": mock.ANY,
|
||||||
|
"canceled_by__trigramme": None,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"errors": {},
|
||||||
|
"warnings": {},
|
||||||
|
"opegroups_to_update": [
|
||||||
|
{
|
||||||
|
"id": group.pk,
|
||||||
|
"amount": str(group.amount),
|
||||||
|
"is_cof": group.is_cof,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.account.refresh_from_db()
|
self.account.refresh_from_db()
|
||||||
|
@ -3643,22 +3665,6 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
self.kpsul_consumer_mock.group_send.assert_called_with(
|
self.kpsul_consumer_mock.group_send.assert_called_with(
|
||||||
"kfet.kpsul",
|
"kfet.kpsul",
|
||||||
{
|
{
|
||||||
"opegroups": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": group.pk,
|
|
||||||
"amount": Decimal("0.00"),
|
|
||||||
"is_cof": False,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"opes": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": operation.pk,
|
|
||||||
"canceled_by__trigramme": None,
|
|
||||||
"canceled_at": self.now + timedelta(seconds=15),
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"checkouts": [{"id": self.checkout.pk, "balance": Decimal("110.75")}],
|
"checkouts": [{"id": self.checkout.pk, "balance": Decimal("110.75")}],
|
||||||
"articles": [],
|
"articles": [],
|
||||||
},
|
},
|
||||||
|
@ -3714,7 +3720,26 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
json_data, {"canceled": [operation.pk], "errors": {}, "warnings": {}}
|
json_data,
|
||||||
|
{
|
||||||
|
"canceled": [
|
||||||
|
{
|
||||||
|
"id": operation.id,
|
||||||
|
# l'encodage des dates en JSON est relou...
|
||||||
|
"canceled_at": mock.ANY,
|
||||||
|
"canceled_by__trigramme": None,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"errors": {},
|
||||||
|
"warnings": {},
|
||||||
|
"opegroups_to_update": [
|
||||||
|
{
|
||||||
|
"id": group.pk,
|
||||||
|
"amount": str(group.amount),
|
||||||
|
"is_cof": group.is_cof,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.account.refresh_from_db()
|
self.account.refresh_from_db()
|
||||||
|
@ -3725,27 +3750,7 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
self.assertEqual(self.checkout.balance, Decimal("100.00"))
|
self.assertEqual(self.checkout.balance, Decimal("100.00"))
|
||||||
|
|
||||||
self.kpsul_consumer_mock.group_send.assert_called_with(
|
self.kpsul_consumer_mock.group_send.assert_called_with(
|
||||||
"kfet.kpsul",
|
"kfet.kpsul", {"checkouts": [], "articles": []},
|
||||||
{
|
|
||||||
"opegroups": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": group.pk,
|
|
||||||
"amount": Decimal("0.00"),
|
|
||||||
"is_cof": False,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"opes": [
|
|
||||||
{
|
|
||||||
"cancellation": True,
|
|
||||||
"id": operation.pk,
|
|
||||||
"canceled_by__trigramme": None,
|
|
||||||
"canceled_at": self.now + timedelta(seconds=15),
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"checkouts": [],
|
|
||||||
"articles": [],
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch("django.utils.timezone.now")
|
@mock.patch("django.utils.timezone.now")
|
||||||
|
@ -3966,13 +3971,33 @@ class KPsulCancelOperationsViewTests(ViewTestCaseMixin, TestCase):
|
||||||
group.refresh_from_db()
|
group.refresh_from_db()
|
||||||
self.assertEqual(group.amount, Decimal("10.75"))
|
self.assertEqual(group.amount, Decimal("10.75"))
|
||||||
self.assertEqual(group.opes.exclude(canceled_at=None).count(), 3)
|
self.assertEqual(group.opes.exclude(canceled_at=None).count(), 3)
|
||||||
|
self.maxDiff = None
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
json_data,
|
json_data,
|
||||||
{
|
{
|
||||||
"canceled": [operation1.pk, operation2.pk],
|
"canceled": [
|
||||||
"warnings": {"already_canceled": [operation3.pk]},
|
{
|
||||||
|
"id": operation1.id,
|
||||||
|
# l'encodage des dates en JSON est relou...
|
||||||
|
"canceled_at": mock.ANY,
|
||||||
|
"canceled_by__trigramme": None,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": operation2.id,
|
||||||
|
# l'encodage des dates en JSON est relou...
|
||||||
|
"canceled_at": mock.ANY,
|
||||||
|
"canceled_by__trigramme": None,
|
||||||
|
},
|
||||||
|
],
|
||||||
"errors": {},
|
"errors": {},
|
||||||
|
"warnings": {"already_canceled": [operation3.pk]},
|
||||||
|
"opegroups_to_update": [
|
||||||
|
{
|
||||||
|
"id": group.pk,
|
||||||
|
"amount": str(group.amount),
|
||||||
|
"is_cof": group.is_cof,
|
||||||
|
}
|
||||||
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue