Skip to content

Commit

Permalink
add value/data/seq properties to message (#326)
Browse files Browse the repository at this point in the history
* add value/data/seq properties to message

* fix bug with transport type enum equality comparison

* more updates to align with pyamqp

* update history file and version

* add tests

* backcompat allow transport_type to be None in auth/common.set_io

* update async client do_work to take kwargs

* update value/seq props to return None if BatchMessage

* drop 3.6

* run mac/linux/windows in parallel

* add max parallel back in

* list apps for xcode debugging purposes

* fix macos ci

* remove dependsOn in test pipeline

* update xcode in test pipeline

* tests yml - set maxParallel: 1

* make test pipeline jobs sequential again b/c of shared resources

* update release date
  • Loading branch information
swathipil authored Aug 17, 2022
1 parent 336ac45 commit 375b99b
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 58 deletions.
37 changes: 12 additions & 25 deletions .azure-pipelines/client.test.live.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ trigger:
- master

variables:
PythonVersion36: '3.6'
PythonVersion37: '3.7'
PythonVersion38: '3.8'
PythonVersion39: '3.9'
Expand All @@ -20,9 +19,6 @@ jobs:
strategy:
maxParallel: 1
matrix:
x64 Python 3.6:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion36)'
x64 Python 3.7:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion37)'
Expand All @@ -35,9 +31,6 @@ jobs:
x64 Python 3.10:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion310)'
x86 Python 3.6:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion36)'
x86 Python 3.7:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion37)'
Expand Down Expand Up @@ -108,19 +101,16 @@ jobs:

- job: 'MacOS'

dependsOn: 'Windows'

timeoutInMinutes: 120

dependsOn: 'Windows'

pool:
vmImage: 'macOS-10.15'
vmImage: 'macOS-11'

strategy:
maxParallel: 1
matrix:
Python 3.6:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion36)'
Python 3.7:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion37)'
Expand All @@ -137,7 +127,6 @@ jobs:
variables:
MacOSXDeploymentTarget: '10.9'
OpenSSLDir: $(Agent.BuildDirectory)/openssl-macosx$(MacOSXDeploymentTarget)
PythonVersion36: '3.6.8'
PythonVersion37: '3.7.6'
PythonVersion38: '3.8.2'
PythonVersion39: '3.9.0'
Expand All @@ -154,8 +143,8 @@ jobs:
pipeline: 119 # azure-uamqp-python - openssl
project: '29ec6040-b234-4e31-b139-33dc4287b756' # public

- script: sudo xcode-select --switch /Applications/Xcode_11.3.1.app
displayName: 'Select Xcode 11.3.1'
- script: sudo xcode-select --switch /Applications/Xcode_13.1.app
displayName: 'Select Xcode 13.1'

- script: source ./install_python_osx.sh
displayName: 'Install Official Python'
Expand Down Expand Up @@ -234,8 +223,6 @@ jobs:
strategy:
maxParallel: 1
matrix:
Python 3.6:
PythonVersion: '$(PythonVersion36)'
Python 3.7:
PythonVersion: '$(PythonVersion37)'
Python 3.8:
Expand Down Expand Up @@ -332,25 +319,25 @@ jobs:
versionSpec: '$(PythonVersion)'
- template: /.azure-pipelines/test-eh-sb-sdk.yml

- job: 'SDK_LiveTest_macOS1015_36'
- job: 'SDK_LiveTest_macOS1015_38'
timeoutInMinutes: 300
dependsOn: 'MacOS'
pool:
name: 'Azure Pipelines'
vmImage: 'macOS-10.15'
vmImage: 'macOS-11'
strategy:
matrix:
EventHub Python 3.6:
EventHub Python 3.8:
SDK: 'EventHub'
ServiceBus Python 3.6:
ServiceBus Python 3.8:
SDK: 'ServiceBus'
variables:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion36)'
PythonVersion: '$(PythonVersion38)'
MacOSXDeploymentTarget: '10.9'
PythonVersion368: '3.6.8'
PythonVersion382: '3.8.2'
OSArch: 'MacOS'
DownloadArtifactFolder: 'uamqp-macosx$(MacOSXDeploymentTarget)-$(PythonVersion368)-whl'
DownloadArtifactFolder: 'uamqp-macosx$(MacOSXDeploymentTarget)-$(PythonVersion382)-whl'
steps:
- template: /.azure-pipelines/use-python-version.yml
parameters:
Expand Down
30 changes: 6 additions & 24 deletions .azure-pipelines/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ trigger:
- master

variables:
PythonVersion36: '3.6'
PythonVersion37: '3.7'
PythonVersion38: '3.8'
PythonVersion39: '3.9'
Expand Down Expand Up @@ -47,13 +46,10 @@ jobs:
- job: 'MacOS'

pool:
vmImage: 'macOS-10.15'
vmImage: 'macOS-11'

strategy:
matrix:
Python 3.6:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion36)'
Python 3.7:
PythonBin: 'python3'
PythonVersion: '$(PythonVersion37)'
Expand All @@ -70,7 +66,6 @@ jobs:
variables:
MacOSXDeploymentTarget: '10.9'
OpenSSLDir: $(Agent.BuildDirectory)/openssl-macosx$(MacOSXDeploymentTarget)
PythonVersion36: '3.6.8'
PythonVersion37: '3.7.6'
PythonVersion38: '3.8.2'
PythonVersion39: '3.9.0'
Expand All @@ -87,8 +82,11 @@ jobs:
pipeline: 119 # azure-uamqp-python - openssl
project: '29ec6040-b234-4e31-b139-33dc4287b756' # public

- script: sudo xcode-select --switch /Applications/Xcode_11.3.1.app
displayName: 'Select Xcode 11.3.1'
- script: sudo ls /Applications/
displayName: 'List All apps'

- script: sudo xcode-select --switch /Applications/Xcode_13.1.app
displayName: 'Select Xcode 13.1'

- script: source ./install_python_osx.sh
displayName: 'Install Official Python'
Expand Down Expand Up @@ -151,9 +149,6 @@ jobs:

strategy:
matrix:
x64 Python 3.6:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion36)'
x64 Python 3.7:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion37)'
Expand All @@ -166,9 +161,6 @@ jobs:
x64 Python 3.10:
PythonArchitecture: 'x64'
PythonVersion: '$(PythonVersion310)'
x86 Python 3.6:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion36)'
x86 Python 3.7:
PythonArchitecture: 'x86'
PythonVersion: '$(PythonVersion37)'
Expand Down Expand Up @@ -233,8 +225,6 @@ jobs:

strategy:
matrix:
Python 3.6:
PythonVersion: '$(PythonVersion36)'
Python 3.7:
PythonVersion: '$(PythonVersion37)'
Python 3.8:
Expand Down Expand Up @@ -298,10 +288,6 @@ jobs:

strategy:
matrix:
Python36m-manylinux1:
ContainerImage: 'manylinux_crypto_x64'
PythonVersion: 'cp36-cp36m'
Platform: 'manylinux1_x86_64'
Python37m-manylinux1:
ContainerImage: 'manylinux_crypto_x64'
PythonVersion: 'cp37-cp37m'
Expand All @@ -314,10 +300,6 @@ jobs:
ContainerImage: 'manylinux_crypto_x64'
PythonVersion: 'cp39-cp39'
Platform: 'manylinux1_x86_64'
Python36m-manylinux2010:
ContainerImage: 'manylinux2010_crypto_x64'
PythonVersion: 'cp36-cp36m'
Platform: 'manylinux2010_x86_64'
Python37m-manylinux2010:
ContainerImage: 'manylinux2010_crypto_x64'
PythonVersion: 'cp37-cp37m'
Expand Down
10 changes: 10 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Release History
===============

1.6.0 (2022-08-18)
+++++++++++++++++++

This version and all future versions will require Python 3.7+, Python 3.6 is no longer supported.

- Added `data`, `value`, `sequence` properties to `uamqp.Message`, which return the body if the body type corresponds.
- Added `message_annotations` property to `uamqp.Message`, which is an alias for the `annotations` instance variable.
- Added `data` property to `uamqp.BatchMessage`, which returns the iterable body of the batch.
- Added `ttl` property to `uamqp.MessageHeader`, which is an alias for the `time_to_live` instance variable.

1.5.3 (2022-03-23)
+++++++++++++++++++

Expand Down
6 changes: 3 additions & 3 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cython==0.29.21
setuptools>=27.1.2
wheel>=0.32.0
pytest==6.2.4; python_version >= '3.10'
pytest==5.4.1; python_version >= '3.6' and python_version < '3.10'
pytest-asyncio==0.12.0; python_version >= '3.6'
pytest==5.4.1; python_version >= '3.7' and python_version < '3.10'
pytest-asyncio==0.12.0; python_version >= '3.7'
docutils>=0.14
pygments>=2.2.0
pylint==2.3.1; python_version >= '3.6'
pylint==2.3.1; python_version >= '3.7'
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ def build_cmake(self, ext):
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand All @@ -290,5 +289,5 @@ def build_cmake(self, ext):
cmdclass={
'build_ext': build_ext,
},
python_requires=">=3.6",
python_requires=">=3.7",
)
3 changes: 3 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ def hack_open(ins):
assert type(exc) == RuntimeError
client.close()
assert not client._keep_alive_thread

# check that kwargs can be passed to client.do_work
client.do_work(fake_kwarg="ignore")
16 changes: 16 additions & 0 deletions tests/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,18 @@ def test_deepcopy_batch_message():
batch_message = list(message_batch._body_gen)[0]
batch_copy_message = list(message_batch_copy._body_gen)[0]
assert len(list(message_batch._body_gen)) == len(list(message_batch_copy._body_gen))
assert len(list(message_batch.data)) == len(list(message_batch_copy._body_gen))
assert list(list(message_batch.data)[0].data) == list(list(message_batch_copy._body_gen)[0].data)
assert message_batch.value is None
assert message_batch.sequence is None

# check message attributes are equal to deepcopied message attributes
assert list(batch_message.get_data()) == list(batch_copy_message.get_data())
assert batch_message.footer == batch_copy_message.footer
assert batch_message.state == batch_copy_message.state
assert batch_message.application_properties == batch_copy_message.application_properties
assert batch_message.annotations == batch_copy_message.annotations
assert batch_message.annotations == batch_copy_message.message_annotations
assert batch_message.delivery_annotations == batch_copy_message.delivery_annotations
assert batch_message.settled == batch_copy_message.settled
assert batch_message.properties.message_id == batch_copy_message.properties.message_id
Expand All @@ -224,6 +229,7 @@ def test_deepcopy_batch_message():
assert batch_message.properties.reply_to_group_id == batch_copy_message.properties.reply_to_group_id
assert batch_message.header.delivery_count == batch_copy_message.header.delivery_count
assert batch_message.header.time_to_live == batch_copy_message.header.time_to_live
assert batch_message.header.ttl == batch_copy_message.header.time_to_live
assert batch_message.header.first_acquirer == batch_copy_message.header.first_acquirer
assert batch_message.header.durable == batch_copy_message.header.durable
assert batch_message.header.priority == batch_copy_message.header.priority
Expand Down Expand Up @@ -285,6 +291,9 @@ def test_message_body_data_type():
assert check_list[0] == multiple_data[0]
assert check_list[1] == multiple_data[1].encode("UTF-8")
assert str(multiple_data_message)
assert list(multiple_data_message.data) == list(multiple_data_message.get_data())
assert multiple_data_message.value is None
assert multiple_data_message.sequence is None

with pytest.raises(TypeError):
Message(body={"key": "value"}, body_type=MessageBodyType.Data)
Expand Down Expand Up @@ -324,6 +333,10 @@ def test_message_body_value_type():
assert isinstance(string_value_message._body, ValueBody)
assert str(compound_list_value_message)

assert compound_list_value_message.value == compound_list_value_message.get_data()
assert compound_list_value_message.data is None
assert compound_list_value_message.sequence is None


def test_message_body_sequence_type():

Expand All @@ -343,6 +356,9 @@ def test_message_body_sequence_type():
assert check_list[0] == multiple_lists[0]
assert check_list[1] == multiple_lists[1]
assert str(multiple_lists_message)
assert list(multiple_lists_message.sequence) == list(multiple_lists_message.get_data())
assert multiple_lists_message.value is None
assert multiple_lists_message.data is None

with pytest.raises(TypeError):
Message(body={"key": "value"}, body_type=MessageBodyType.Sequence)
Expand Down
2 changes: 1 addition & 1 deletion uamqp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
pass # Async not supported.


__version__ = "1.5.3"
__version__ = "1.6.0"


_logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion uamqp/async_ops/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ async def client_ready_async(self):
return False
return True

async def do_work_async(self):
async def do_work_async(self, **kwargs): # pylint: disable=unused-argument
"""Run a single connection iteration asynchronously.
This will return `True` if the connection is still open
and ready to be used for further work, or `False` if it needs
Expand Down
2 changes: 1 addition & 1 deletion uamqp/authentication/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _encode(self, value):
return value.encode(self._encoding) if isinstance(value, six.text_type) else value

def set_io(self, hostname, port, http_proxy, transport_type):
if transport_type == TransportType.AmqpOverWebsocket or http_proxy is not None:
if transport_type and transport_type.value == TransportType.AmqpOverWebsocket.value or http_proxy is not None:
self.set_wsio(hostname, port or constants.DEFAULT_AMQP_WSS_PORT, http_proxy)
else:
self.set_tlsio(hostname, port or constants.DEFAULT_AMQPS_PORT)
Expand Down
2 changes: 1 addition & 1 deletion uamqp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def client_ready(self):
return False
return True

def do_work(self):
def do_work(self, **kwargs): # pylint: disable=unused-argument
"""Run a single connection iteration.
This will return `True` if the connection is still open
and ready to be used for further work, or `False` if it needs
Expand Down
Loading

0 comments on commit 375b99b

Please sign in to comment.