Skip to content

Commit

Permalink
Add unit test testing the ordersearchform description
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasvdh92 committed Apr 16, 2024
1 parent 0bb9e3b commit 43a8876
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/unit/customer/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from datetime import date, datetime
from unittest import mock

Expand Down Expand Up @@ -67,3 +69,32 @@ def test_get_filters(self):
"number__contains": "100",
},
)

@pytest.mark.parametrize(
"date_from, date_to, order_number, expected_description",
[
("2023-01-01", "2023-01-02", "100", "Orders placed between 2023-01-01 and 2023-01-02 and order number "
"containing 100"),
("2023-01-01", "2023-01-02", "", "Orders placed between 2023-01-01 and 2023-01-02"),
("2023-01-01", "", "100", "Orders placed since 2023-01-01 and order number containing 100"),
("2023-01-01", "", "", "Orders placed since 2023-01-01"),
("", "2023-01-02", "100", "Orders placed until 2023-01-02 and order number containing 100"),
("", "2023-01-02", "", "Orders placed since 2023-01-02"),
("", "", "100", "Orders with order number containing 100"),
("", "", "", None),
]
)
def test_orders_descriptions(self, date_from, date_to, order_number, expected_description):
form = OrderSearchForm(
data={
"date_from": date_from,
"date_to": date_to,
"order_number": order_number,
}
)
self.assertTrue(form.is_valid())

self.assertEqual(
form.orders_description,
expected_description,
)

0 comments on commit 43a8876

Please sign in to comment.