Repository: redis/redis-py

Issue:
xpending_range does not pass consumername in command any more
**Version**: What redis-py and what redis version is the issue happening on? latest HEAD - 9419f1d56beff5b350c87785cc57f2431fe85cbb

**Platform**: python 3 on linux

**Description**: `xpending_range()` accepts an optional `consumername` argument but does not actually use it.

Here is xpending doc, consumer is last parameter: https://redis.io/commands/XPENDING

The redis-py `xpending_range()` accepts the `consumername` param but does not actually use it:

https://github.com/andymccurdy/redis-py/blob/9419f1d56beff5b350c87785cc57f2431fe85cbb/redis/commands.py#L2037-L2076

In case it's not obvious, then here is an example invocation and the corresponding REDIS command (via MONITOR):

```python
>>> db.xpending_range(key, group, start, stop, count, consumer)  # consumer = 'ts1'
```

Redis output (consumer is missing):

```
+1633567393.619941 [15 127.0.0.1:44492] "XPENDING" "sa" "cgabc" "-" "+" "1000"
```


Discussion:
This is the commit that introduced the bug: 9c60670deea5c593e20204bbd5f172ccfcd1d9db

Probably should've been caught by tests.
@AvitalFineRedis Please have a look.

Resolving patch:
diff --git a/redis/commands.py b/redis/commands.py
--- a/redis/commands.py
+++ b/redis/commands.py
@@ -2034,18 +2034,21 @@ def xpending(self, name, groupname):
         """
         return self.execute_command('XPENDING', name, groupname)
 
-    def xpending_range(self, name, groupname, min, max, count,
-                       consumername=None, idle=None):
+    def xpending_range(self, name, groupname, idle=None,
+                       min=None, max=None, count=None,
+                       consumername=None):
         """
         Returns information about pending messages, in a range.
+
         name: name of the stream.
         groupname: name of the consumer group.
+        idle: available from  version 6.2. filter entries by their
+        idle-time, given in milliseconds (optional).
         min: minimum stream ID.
         max: maximum stream ID.
         count: number of messages to return
         consumername: name of a consumer to filter by (optional).
-        idle: available from  version 6.2. filter entries by their
-        idle-time, given in milliseconds (optional).
+
         """
         if {min, max, count} == {None}:
             if idle is not None or consumername is not None:
@@ -2072,6 +2075,9 @@ def xpending_range(self, name, groupname, min, max, count,
             pieces.extend([min, max, count])
         except TypeError:
             pass
+        # consumername
+        if consumername:
+            pieces.append(consumername)
 
         return self.execute_command('XPENDING', *pieces, parse_detail=True)
 


Test patch:
diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -3126,6 +3126,14 @@ def test_xpending_range(self, r):
         assert response[1]['message_id'] == m2
         assert response[1]['consumer'] == consumer2.encode()
 
+        # test with consumer name
+        response = r.xpending_range(stream, group,
+                                    min='-', max='+', count=5,
+                                    consumername=consumer1)
+        assert len(response) == 1
+        assert response[0]['message_id'] == m1
+        assert response[0]['consumer'] == consumer1.encode()
+
     @skip_if_server_version_lt('6.2.0')
     def test_xpending_range_idle(self, r):
         stream = 'stream'