Skip to content

Commit 81c218d

Browse files
committed
kind should be optional
1 parent 75cbed7 commit 81c218d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

stream/reactions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ def add_child(self, kind, parent_id, user_id, data=None, target_feeds=None):
4646
"reaction/", service_name="api", signature=self.token, data=payload
4747
)
4848

49-
def filter(self, kind, **params):
49+
def filter(self, **params):
5050
lookup_field = ""
5151
lookup_value = ""
52+
kind = None
53+
54+
if "kind" in params:
55+
kind = params.pop("kind")
5256

5357
if "reaction_id" in params:
5458
lookup_field = "reaction_id"
@@ -60,8 +64,12 @@ def filter(self, kind, **params):
6064
lookup_field = "user_id"
6165
lookup_value = params.pop("user_id")
6266

67+
endpoint = "reaction/%s/%s/" % (lookup_field, lookup_value)
68+
if kind is not None:
69+
endpoint = "reaction/%s/%s/%s/" % (lookup_field, lookup_value, kind)
70+
6371
return self.client.get(
64-
"reaction/%s/%s/%s/" % (lookup_field, lookup_value, kind),
72+
endpoint,
6573
service_name="api",
6674
signature=self.token,
6775
params=params,

stream/tests/test_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,12 +1243,10 @@ def test_reaction_filter_random(self):
12431243
id_lte="54a60c1e-4ee3-494b-a1e3-50c06acb5ed4",
12441244
)
12451245
self.c.reactions.filter(
1246-
kind="dunno",
12471246
activity_id="54a60c1e-4ee3-494b-a1e3-50c06acb5ed4",
12481247
id_lte="54a60c1e-4ee3-494b-a1e3-50c06acb5ed4",
12491248
)
12501249
self.c.reactions.filter(
1251-
kind="val",
12521250
user_id="mike", id_lte="54a60c1e-4ee3-494b-a1e3-50c06acb5ed4"
12531251
)
12541252

@@ -1269,7 +1267,7 @@ def test_reaction_filter(self):
12691267
response = self.c.reactions.add("comment", activity_id, user)
12701268
reaction_comment = self.c.reactions.get(response["id"])
12711269

1272-
r = self.c.reactions.filter(kind="like", reaction_id=reaction["id"])
1270+
r = self.c.reactions.filter(reaction_id=reaction["id"])
12731271
self._first_result_should_be(r, child)
12741272

12751273
r = self.c.reactions.filter(kind="like", activity_id=activity_id, id_lte=reaction["id"])

0 commit comments

Comments
 (0)