nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ably/ably-python
Pull request #510 (2023-06-05 13:59:31)

refactor: use integer api_version
See [`CSV2a`](https://sdk.ably.com/builds/ably/specification/main/features/#CSV2a)


Patch:
diff --git a/ably/__init__.py b/ably/__init__.py
index 793818f..37e2acb 100644
--- a/ably/__init__.py
+++ b/ably/__init__.py
@@ -14,5 +14,5 @@ import logging
 logger = logging.getLogger(__name__)
 logger.addHandler(logging.NullHandler())
 
-api_version = '2.0'
+api_version = '2'
 lib_version = '2.0.0-beta.6'


Test patch:
diff --git a/test/ably/rest/resthttp_test.py b/test/ably/rest/resthttp_test.py
index 9aa512f..79daffe 100644
--- a/test/ably/rest/resthttp_test.py
+++ b/test/ably/rest/resthttp_test.py
@@ -187,7 +187,7 @@ class TestRestHttp(BaseAsyncTestCase):
 
         # API
         assert 'X-Ably-Version' in r.request.headers
-        assert r.request.headers['X-Ably-Version'] == '2.0'
+        assert r.request.headers['X-Ably-Version'] == '2'
 
         # Agent
         assert 'Ably-Agent' in r.request.headers
Repository: ably/ably-python
Pull request #519 (2023-08-18 14:45:51)

Fixed connection id key while updating inner message fields


Patch:
diff --git a/ably/types/message.py b/ably/types/message.py
index cb440dc..b3349de 100644
--- a/ably/types/message.py
+++ b/ably/types/message.py
@@ -204,8 +204,8 @@ class Message(EncodeDataMixin):
     def __update_empty_fields(proto_msg: dict, msg: dict, msg_index: int):
         if msg.get("id") is None or msg.get("id") == '':
             msg['id'] = f"{proto_msg.get('id')}:{msg_index}"
-        if msg.get("connectionid") is None or msg.get("connectionid") == '':
-            msg['connectionid'] = proto_msg.get('connectionid')
+        if msg.get("connectionId") is None or msg.get("connectionId") == '':
+            msg['connectionId'] = proto_msg.get('connectionId')
         if msg.get("timestamp") is None or msg.get("timestamp") == 0:
             msg['timestamp'] = proto_msg.get('timestamp')
 


Test patch:
diff --git a/test/unit/message_test.py b/test/unit/message_test.py
index 419ab35..b09e0fc 100644
--- a/test/unit/message_test.py
+++ b/test/unit/message_test.py
@@ -5,12 +5,12 @@ import ably.types.message
 def test_update_inner_message_fields_tm2():
     proto_msg: dict = {
         'id': 'abcdefg',
-        'connectionid': 'custom_connection_id',
+        'connectionId': 'custom_connection_id',
         'timestamp': 23134,
         'messages': [
             {
                 'event': 'test',
-                'data': 'hello there'
+                'data': 'hello there'''
             }
         ]
     }
@@ -19,7 +19,7 @@ def test_update_inner_message_fields_tm2():
     msg_index = 0
     for msg in messages:
         assert msg.get('id') == f"abcdefg:{msg_index}"
-        assert msg.get('connectionid') == 'custom_connection_id'
+        assert msg.get('connectionId') == 'custom_connection_id'
         assert msg.get('timestamp') == 23134
         msg_index = msg_index + 1
 
@@ -28,7 +28,7 @@ def test_update_inner_message_fields_tm2():
 def test_update_inner_message_fields_for_presence_msg_tm2():
     proto_msg: dict = {
         'id': 'abcdefg',
-        'connectionid': 'custom_connection_id',
+        'connectionId': 'custom_connection_id',
         'timestamp': 23134,
         'presence': [
             {
@@ -45,6 +45,6 @@ def test_update_inner_message_fields_for_presence_msg_tm2():
     for presence_msg in presence_messages:
         msg = presence_msg.get('message')
         assert msg.get('id') == f"abcdefg:{msg_index}"
-        assert msg.get('connectionid') == 'custom_connection_id'
+        assert msg.get('connectionId') == 'custom_connection_id'
         assert msg.get('timestamp') == 23134
         msg_index = msg_index + 1
Repository: ably/ably-python
Pull request #520 (2023-08-18 15:08:54)

Removed unavailable presence nested message from the code


Patch:
diff --git a/ably/types/message.py b/ably/types/message.py
index b3349de..240ab17 100644
--- a/ably/types/message.py
+++ b/ably/types/message.py
@@ -222,7 +222,7 @@ class Message(EncodeDataMixin):
         if presence_messages is not None:
             msg_index = 0
             for presence_msg in presence_messages:
-                Message.__update_empty_fields(proto_msg, presence_msg.get('message'), msg_index)
+                Message.__update_empty_fields(proto_msg, presence_msg, msg_index)
                 msg_index = msg_index + 1
 
 


Test patch:
diff --git a/test/unit/message_test.py b/test/unit/message_test.py
index b09e0fc..4902d6b 100644
--- a/test/unit/message_test.py
+++ b/test/unit/message_test.py
@@ -32,10 +32,8 @@ def test_update_inner_message_fields_for_presence_msg_tm2():
         'timestamp': 23134,
         'presence': [
             {
-                'message': {
-                    'event': 'test',
-                    'data': 'hello there'
-                },
+                'event': 'test',
+                'data': 'hello there'
             }
         ]
     }
@@ -43,8 +41,7 @@ def test_update_inner_message_fields_for_presence_msg_tm2():
     presence_messages: list[dict] = proto_msg.get('presence')
     msg_index = 0
     for presence_msg in presence_messages:
-        msg = presence_msg.get('message')
-        assert msg.get('id') == f"abcdefg:{msg_index}"
-        assert msg.get('connectionId') == 'custom_connection_id'
-        assert msg.get('timestamp') == 23134
+        assert presence_msg.get('id') == f"abcdefg:{msg_index}"
+        assert presence_msg.get('connectionId') == 'custom_connection_id'
+        assert presence_msg.get('timestamp') == 23134
         msg_index = msg_index + 1