summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 770b57d86..31b7c6f3b 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -3367,6 +3367,28 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText):
]
self._test_search(c, result, context="Boolean search")
+ # date searches
+ search_created_q = str(pgettext("key for text search", "created"))
+ today = datetime.date.today().strftime('%Y-%m-%d')
+ result = [
+ (f'{search_created_q}="{today}"', len(self.operations)),
+ ]
+ self._test_search(c, result, context="Exact date search")
+ yesterday = (datetime.date.today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
+ result = [
+ (f'{search_created_q}="{yesterday}"', 0),
+ ]
+ self._test_search(c, result, context="Exact date search - no match")
+ result = [
+ (f'{search_created_q}=>"{yesterday}"', len(self.operations)),
+ ]
+ self._test_search(c, result, context="After date search")
+ tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
+ result = [
+ (f'{search_created_q}=<"{tomorrow}"', len(self.operations)),
+ ]
+ self._test_search(c, result, context="Before date search")
+
def test_mixed_search_vector(self):
operation_1 = models.Operation.objects.get(pk=self.operations[0].pk)
operation_1.common_name = "Opération : Château de Fougères"