mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-09-22 09:28:32 +00:00
Fix: Set the document modified dates to hopefully prevent this flake. Good across 30 runs at least
This commit is contained in:
@@ -1057,33 +1057,52 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase):
|
|||||||
THEN:
|
THEN:
|
||||||
- The similar documents are returned from the API request
|
- The similar documents are returned from the API request
|
||||||
"""
|
"""
|
||||||
# Distinct created/added dates: documents created at the same instant
|
# Distinct created/added/modified dates: documents sharing a timestamp
|
||||||
# share a timestamp term, and more_like_this (which cannot be scoped to
|
# term (down to the second) would be matched on it by more_like_this
|
||||||
# content fields) would then match on it, surfacing unrelated documents.
|
# (which cannot be scoped to content fields), surfacing unrelated
|
||||||
d1 = DocumentFactory(
|
# documents. `modified` is auto_now, so it can't be set via factory
|
||||||
title="invoice",
|
# kwargs like created/added - freeze time per document instead so all
|
||||||
content="the thing i bought at a shop and paid with bank account",
|
# three date fields land on distinct seconds.
|
||||||
created=datetime.date(2018, 1, 1),
|
with time_machine.travel(
|
||||||
added=timezone.make_aware(datetime.datetime(2018, 1, 1)),
|
timezone.make_aware(datetime.datetime(2018, 1, 1)),
|
||||||
)
|
tick=False,
|
||||||
d2 = DocumentFactory(
|
):
|
||||||
title="bank statement 1",
|
d1 = DocumentFactory(
|
||||||
content="things i paid for in august",
|
title="invoice",
|
||||||
created=datetime.date(2019, 3, 4),
|
content="the thing i bought at a shop and paid with bank account",
|
||||||
added=timezone.make_aware(datetime.datetime(2019, 3, 4)),
|
created=datetime.date(2018, 1, 1),
|
||||||
)
|
added=timezone.make_aware(datetime.datetime(2018, 1, 1)),
|
||||||
d3 = DocumentFactory(
|
)
|
||||||
title="bank statement 3",
|
with time_machine.travel(
|
||||||
content="things i paid for in september",
|
timezone.make_aware(datetime.datetime(2019, 3, 4)),
|
||||||
created=datetime.date(2020, 7, 9),
|
tick=False,
|
||||||
added=timezone.make_aware(datetime.datetime(2020, 7, 9)),
|
):
|
||||||
)
|
d2 = DocumentFactory(
|
||||||
d4 = DocumentFactory(
|
title="bank statement 1",
|
||||||
title="Quarterly Report",
|
content="things i paid for in august",
|
||||||
content="quarterly revenue profit margin earnings growth",
|
created=datetime.date(2019, 3, 4),
|
||||||
created=datetime.date(2021, 11, 30),
|
added=timezone.make_aware(datetime.datetime(2019, 3, 4)),
|
||||||
added=timezone.make_aware(datetime.datetime(2021, 11, 30)),
|
)
|
||||||
)
|
with time_machine.travel(
|
||||||
|
timezone.make_aware(datetime.datetime(2020, 7, 9)),
|
||||||
|
tick=False,
|
||||||
|
):
|
||||||
|
d3 = DocumentFactory(
|
||||||
|
title="bank statement 3",
|
||||||
|
content="things i paid for in september",
|
||||||
|
created=datetime.date(2020, 7, 9),
|
||||||
|
added=timezone.make_aware(datetime.datetime(2020, 7, 9)),
|
||||||
|
)
|
||||||
|
with time_machine.travel(
|
||||||
|
timezone.make_aware(datetime.datetime(2021, 11, 30)),
|
||||||
|
tick=False,
|
||||||
|
):
|
||||||
|
d4 = DocumentFactory(
|
||||||
|
title="Quarterly Report",
|
||||||
|
content="quarterly revenue profit margin earnings growth",
|
||||||
|
created=datetime.date(2021, 11, 30),
|
||||||
|
added=timezone.make_aware(datetime.datetime(2021, 11, 30)),
|
||||||
|
)
|
||||||
backend = get_backend()
|
backend = get_backend()
|
||||||
backend.add_or_update(d1)
|
backend.add_or_update(d1)
|
||||||
backend.add_or_update(d2)
|
backend.add_or_update(d2)
|
||||||
|
|||||||
Reference in New Issue
Block a user