Cc: Mauro Carvalho Chehab <[email protected]>
Suggested-by: Stephen Finucane <[email protected]>
Signed-off-by: Johan Herland <[email protected]>
---
patchwork/api/filters.py | 5 ++++-
patchwork/tests/api/test_event.py | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/patchwork/api/filters.py b/patchwork/api/filters.py
index 6b4d84c..60f1a36 100644
--- a/patchwork/api/filters.py
+++ b/patchwork/api/filters.py
@@ -236,7 +236,10 @@ class EventFilterSet(TimestampMixin, BaseFilterSet):
class Meta:
model = Event
- fields = ('project', 'category', 'series', 'patch', 'cover')
+ fields = ('project', 'category', 'series', 'patch', 'cover', 'actor')
+ versioned_fields = {
+ '1.2': ('actor', ),
+ }
class BundleFilterSet(BaseFilterSet):
diff --git a/patchwork/tests/api/test_event.py
b/patchwork/tests/api/test_event.py
index 456f2f5..e86e170 100644
--- a/patchwork/tests/api/test_event.py
+++ b/patchwork/tests/api/test_event.py
@@ -156,6 +156,28 @@ class TestEventAPI(utils.APITestCase):
resp = self.client.get(self.api_url(), {'series': 999999})
self.assertEqual(0, len(resp.data))
+ def test_list_filter_actor(self):
+ """Filter events by actor."""
+ events = self._create_events()
+
+ # The final two events (patch-delegated, patch-state-changed)
+ # have an actor set
+ actor = events[0].actor
+ resp = self.client.get(self.api_url(), {'actor': actor.pk})
+ self.assertEqual(2, len(resp.data))
+
+ resp = self.client.get(self.api_url(), {'actor': 'foo-bar'})
+ self.assertEqual(0, len(resp.data))
+
+ def test_list_filter_actor_version_1_1(self):
+ """Filter events by actor using API v1.1."""
+ events = self._create_events()
+
+ # we still see all the events since the actor field is ignored
+ resp = self.client.get(self.api_url(version='1.1'),
+ {'actor': 'foo-bar'})
+ self.assertEqual(len(events), len(resp.data))
+
def test_order_by_date_default(self):
"""Assert the default ordering is by date descending."""
self._create_events()
--
2.19.2
_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork