Skip to content

Commit

Permalink
fix inconsistent InstanceId in GetMdibResponse (#346)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the title above -->
<!--- Link the corresponding issues after you created the pull request
-->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [x] I have updated the [changelog](../CHANGELOG.md) accordingly.
- [ ] I have added tests to cover my changes.
  • Loading branch information
deichmab-draeger authored Feb 21, 2024
1 parent 382e097 commit 01b1171
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.1] - 2024-02-21

### Fixed
- inconsistent InstanceId attributes in GetMdibResponse

## [2.0.0] - 2024-02-14

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions src/sdc11073/mdib/mdibbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ def _reconstruct_mdib(self, add_context_states: bool) -> xml_utils.LxmlElement:
mdib_node = etree_.Element(msg.Mdib, nsmap=doc_nsmap)
mdib_node.set('MdibVersion', str(self.mdib_version))
mdib_node.set('SequenceId', self.sequence_id)
if self.instance_id is not None:
mdib_node.set('InstanceId', str(self.instance_id))
md_description_node = self._reconstruct_md_description()
mdib_node.append(md_description_node)

Expand Down
1 change: 1 addition & 0 deletions tests/mockstuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def __init__(self, wsdiscovery: WsDiscoveryProtocol,
serial_number='12345')

device_mdib_container = ProviderMdib.from_string(mdib_xml_data, log_prefix=log_prefix)
device_mdib_container.instance_id = 1 # set the optional value
# set Metadata
mdsDescriptors = device_mdib_container.descriptions.NODETYPE.get(pm.MdsDescriptor)
for mdsDescriptor in mdsDescriptors:
Expand Down
8 changes: 7 additions & 1 deletion tests/test_client_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from sdc11073.loghelper import basic_logging_setup, get_logger_adapter
from sdc11073.mdib import ConsumerMdib
from sdc11073.pysoap.msgfactory import CreatedMessage
from sdc11073.pysoap.msgreader import MdibVersionGroupReader
from sdc11073.pysoap.soapclient import HTTPReturnCodeError
from sdc11073.pysoap.soapclient_async import SoapClientAsync
from sdc11073.pysoap.soapenvelope import Soap12Envelope, faultcodeEnum
Expand Down Expand Up @@ -527,6 +528,12 @@ def tearDown(self):
def test_basic_connect(self):
runtest_basic_connect(self, self.sdc_client)
runtest_directed_probe(self, self.sdc_client, self.sdc_device)
cl_get_service = self.sdc_client.client('Get')
get_request_result = cl_get_service.get_mdib()
# verify that mdib version groups are identical in elements GetMdibResponse and Mdib
mdib_version_group1 = MdibVersionGroupReader.from_node(get_request_result.p_msg.msg_node)
mdib_version_group2 = MdibVersionGroupReader.from_node(get_request_result.p_msg.msg_node[0])
self.assertEqual(mdib_version_group1, mdib_version_group2)

def test_renew_get_status(self):
for s in self.sdc_client._subscription_mgr.subscriptions.values():
Expand Down Expand Up @@ -719,7 +726,6 @@ def test_get_md_description_parameters(self):

def test_instance_id(self):
""" verify that the client receives correct EpisodicMetricReports and PeriodicMetricReports"""
self.assertIsNone(self.sdc_device.mdib.instance_id)
cl_mdib = ConsumerMdib(self.sdc_client)
cl_mdib.init_mdib()
self.assertEqual(self.sdc_device.mdib.sequence_id, cl_mdib.sequence_id)
Expand Down

0 comments on commit 01b1171

Please sign in to comment.