This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a commit to branch dw/solr_delete_history
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/dw/solr_delete_history by this
push:
new 439c5032f fixup! fixup! fully delete history snapshots when deleting
artifacts (incl remove from solr)
439c5032f is described below
commit 439c5032f88579a486dd537eb4bc9274945f3a32
Author: Dillon Walls <[email protected]>
AuthorDate: Wed Nov 15 21:50:58 2023 +0000
fixup! fixup! fully delete history snapshots when deleting artifacts (incl
remove from solr)
---
Allura/allura/tests/model/test_artifact.py | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/Allura/allura/tests/model/test_artifact.py
b/Allura/allura/tests/model/test_artifact.py
index 74070d838..aed8add97 100644
--- a/Allura/allura/tests/model/test_artifact.py
+++ b/Allura/allura/tests/model/test_artifact.py
@@ -21,8 +21,8 @@ Model tests for artifact
import re
from datetime import datetime
-from tg import tmpl_context as c
-from mock import patch
+from tg import tmpl_context as c, app_globals as g
+from mock import patch, Mock
import pytest
from ming.odm.odmsession import ThreadLocalODMSession
from ming.odm import Mapper
@@ -145,6 +145,7 @@ class TestArtifact:
assert re.match(r'%[email protected]' %
str(p._id), p.message_id())
+ @patch('allura.tasks.mail_tasks.sendmail', Mock())
def test_versioning(self):
pg = WM.Page(title='TestPage3')
with patch('allura.model.artifact.request', Request.blank('/',
remote_addr='1.1.1.1')):
@@ -170,11 +171,24 @@ class TestArtifact:
ThreadLocalODMSession.flush_all()
assert ss.text != pg.text
assert pg.history().count() == 3
+
_id = pg._id
- WM.PageHistory.query.find({'artifact_id': _id}).count() == 3
+ M.MonQTask.run_ready()
+ assert g.solr.search('id:' + pg.index_id()).hits == 1
+ ph = WM.PageHistory.query.find({'artifact_id': _id, 'version':
2}).first()
+ assert ph
+ ph_index = ph.index_id()
+ solr_hist = g.solr.search('id:' + ph_index)
+ if not solr_hist: # sometimes history doesn't get added to solr
+ g.solr.add([ph.solarize()])
+ g.solr.commit()
+ assert g.solr.search('id:' + ph_index).hits == 1
pg.delete()
ThreadLocalODMSession.flush_all()
+ M.MonQTask.run_ready()
WM.PageHistory.query.find({'artifact_id': _id}).count() == 0
+ # history should be deleted from solr
+ assert g.solr.search('id:' + ph_index).hits == 0
def test_messages_unknown_lookup(self):
from bson import ObjectId