Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only subscribe if actions are available #403

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.12"

Expand All @@ -43,7 +43,7 @@ jobs:
echo TARGZ=$(echo dist/*.tar.gz) >> $GITHUB_OUTPUT

- name: Archive package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: distributions
path: dist
Expand All @@ -55,22 +55,22 @@ jobs:
strategy:
matrix:
python-version: [ "3.7", "3.8" , "3.9", "3.10", "3.11", "3.12" ]
os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-22.04, windows-latest ]
distribution: [ "${{ needs.build.outputs.WHL }}",
"${{ needs.build.outputs.TARGZ }}" ]
runs-on: ${{ matrix.os }}

steps:
- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Download Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: distributions
path: dist
Expand All @@ -79,7 +79,7 @@ jobs:
run: pip install ${{ matrix.distribution }}[test]

- name: Detect suffix on ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
echo SUFFIX=$(python -c "import pathlib;p=pathlib.Path('${{ matrix.distribution }}');print('whl') if p.suffix=='.whl' else print('tar_gz')") >> $GITHUB_ENV

Expand All @@ -99,18 +99,18 @@ jobs:
--log-file pytest_${{ matrix.os }}_py${{ matrix.python-version }}_${{ env.SUFFIX }}.log

- name: Archive test result
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: success() || failure() # upload artifacts also if test stage failed
with:
name: unittest_reports
name: unittest_report_${{ matrix.os }}_py${{ matrix.python-version }}_${{ env.SUFFIX }}.html
path: pytest_reports/unittest_report_${{ matrix.os }}_py${{ matrix.python-version }}_${{ env.SUFFIX }}.html
retention-days: 5

- name: Archive test log
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: success() || failure() # upload artifacts also if test stage failed
with:
name: pytest_logs
name: pytest_${{ matrix.os }}_py${{ matrix.python-version }}_${{ env.SUFFIX }}.log
path: pytest_${{ matrix.os }}_py${{ matrix.python-version }}_${{ env.SUFFIX }}.log
retention-days: 5

Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Download Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: distributions
path: dist/
Expand All @@ -46,19 +46,20 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download Build
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: distributions
path: dist

- name: Download Unittest report
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: unittest_reports
pattern: unittest_report_*
path: pytest_reports/
merge-multiple: true

- name: Zip unittest reports
uses: vimtor/[email protected]
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- accessing a multikey may lead to IndexError [#359](https://github.com/Draegerwerk/sdc11073/issues/359)
- fixed a bug where `log_prefix` can only be a string [#393](https://github.com/Draegerwerk/sdc11073/issues/393)
- only send subscribe request if there are actions to subscribe to [#402](https://github.com/Draegerwerk/sdc11073/issues/402)

## [1.3.2] - 2024-03-18

Expand Down
3 changes: 3 additions & 0 deletions src/sdc11073/sdcclient/sdcclientimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ def startAll(self, notSubscribedActions=None, subscriptionsCheckInterval=None, a
subscribe_actions = set(available_actions) - notSubscribedActionsSet
if not subscribe_periodic_reports:
subscribe_actions -= set(periodic_actions)
if not subscribe_actions:
self._logger.warning('startAll: no actions to subscribe for service_id = {}', service_id)
continue
try:
self._subscribe(dpwsHosted, subscribe_actions,
self._onAnyStateEventReport)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_client_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from sdc11073 import namespaces
from sdc11073 import observableproperties
from sdc11073 import pmtypes
from sdc11073.definitions_sdc import SDC_v1_Definitions
from sdc11073.location import SdcLocation
from sdc11073.mdib import ClientMdibContainer
from sdc11073.mdib import clientmdib
Expand Down Expand Up @@ -1756,6 +1757,13 @@ def test_invalid_request(self):
else:
self.assertTrue(False, 'HTTPReturnCodeError not raised')

def test_subscribe_not_all(self):
self.sdcClient_Final.stopAll()
with mock.patch.object(self.sdcClient_Final._logger, 'warning') as mock_logger:
self.sdcClient_Final.startAll(notSubscribedActions=[SDC_v1_Definitions.Actions.OperationInvokedReport])
self.assertFalse(self.sdcClient_Final.all_subscribed)
mock_logger.assert_any_call('startAll: no actions to subscribe for service_id = {}', 'SetService')


class Test_DeviceCommonHttpServer(unittest.TestCase):
@classmethod
Expand Down
Loading