Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
api/search.py | 4 ++--
mods/maintainer.py | 2 +-
tests/test_maintainers.py | 22 ++++++++++++++++++++++
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/api/search.py b/api/search.py
index 08b40c3..2e43421 100644
--- a/api/search.py
+++ b/api/search.py
@@ -427,7 +427,7 @@ Search text keyword in the email message. Example:
return queryset.filter(q)
- def query_test_message(self, query, message):
+ def query_test_message(self, query, message, user=None):
queryset = Message.objects.filter(id=message.id)
terms = [x.strip() for x in query.split() if x.strip()]
- return self.search_series(*terms, queryset=queryset).first()
+ return self.search_series(*terms, user=user, queryset=queryset).first()
diff --git a/mods/maintainer.py b/mods/maintainer.py
index c246d8a..966eb05 100644
--- a/mods/maintainer.py
+++ b/mods/maintainer.py
@@ -69,7 +69,7 @@ class MaintainerModule(PatchewModule):
def _update_watch_queue(self, series):
se = SearchEngine()
for wq in WatchedQuery.objects.all():
- if se.query_test_message(wq.query, series):
+ if se.query_test_message(wq.query, series, wq.user):
self._add_to_queue(wq.user, series, "watched")
else:
self._drop_from_queue(wq.user, series, "watched")
diff --git a/tests/test_maintainers.py b/tests/test_maintainers.py
index 91ad044..5f1fcc5 100755
--- a/tests/test_maintainers.py
+++ b/tests/test_maintainers.py
@@ -88,6 +88,28 @@ class MaintainerQueueTest(PatchewTestCase):
assert q
assert q.message.id == msg.id
+ def test_update_watch_with_user_me(self):
+ wq = WatchedQuery(user=self.testuser, query="to:qemu-block@nongnu.org -nack:me")
+ wq.save()
+ self.cli_import("0001-simple-patch.mbox.gz")
+ msg = Message.objects.first()
+ query = QueuedSeries.objects.filter(user=self.testuser, name="watched")
+ q = query.first()
+ assert q
+ assert q.message.id == msg.id
+
+ # TODO: support and use REST API
+ self.client.post("/login/", {"username": "test", "password": "1234"})
+ self.client.get("/mark-as-rejected/" + msg.message_id + "/")
+ query = QueuedSeries.objects.filter(user=self.testuser, name="reject")
+ q = query.first()
+ assert q
+ assert q.message.id == msg.id
+
+ query = QueuedSeries.objects.filter(user=self.testuser, name="watched")
+ q = query.first()
+ assert not q
+
if __name__ == "__main__":
main()
--
2.34.1
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/patchew-devel