Skip to content

Commit

Permalink
fix: removed push from actions to allow builds to succeed
Browse files Browse the repository at this point in the history
* refactor: Added unit tests for exceptions

- Added more unit tests for exceptions thrown by run_gateway_mfr_result
- Added ResourceBusyError exception to run_gateway_mfr_result

* fix: Remove push action from git CI workflow

- Removed the push action causing the error from protected branch
- Bumped version from 0.11.7 -> 0.11.8

* fix: linting lines too long

* Removed the commented lines
  • Loading branch information
Sebastian Maj authored Nov 15, 2021
1 parent 95676fa commit ddd2943
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.11.7
current_version = 0.11.8
commit = True
tag = True

Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/publish-to-pypi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ jobs:
bump2version patch setup.py
if: github.ref == 'refs/heads/master'

- name: Push Commit from Bump2Version
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
if: github.ref == 'refs/heads/master'

- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/ .
Expand Down
7 changes: 6 additions & 1 deletion hm_pyhelper/miner_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import subprocess
import json
from retry import retry
from hm_pyhelper.lock_singleton import lock_ecc
from hm_pyhelper.lock_singleton import ResourceBusyError, lock_ecc
from hm_pyhelper.logger import get_logger
from hm_pyhelper.exceptions import MalformedRegionException, \
SPIUnavailableException, ECCMalfunctionException, \
Expand Down Expand Up @@ -50,6 +50,11 @@ def run_gateway_mfr(args):
LOGGER.exception(err_str)
raise GatewayMFRFileNotFoundException(err_str) \
.with_traceback(e.__traceback__)
except ResourceBusyError as e:
err_str = "resource busy error: %s"
LOGGER.exception(err_str % str(e))
raise ResourceBusyError(e)\
.with_traceback(e.__traceback__)
except Exception as e:
err_str = "Exception occured on running gateway_mfr %s" \
% str(e)
Expand Down
31 changes: 28 additions & 3 deletions hm_pyhelper/tests/test_miner_param.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from hm_pyhelper.exceptions import MinerFailedToFetchMacAddress
from hm_pyhelper.miner_param import retry_get_region, await_spi_available, \
provision_key, did_gateway_mfr_test_result_include_miner_key_pass, \
from hm_pyhelper.exceptions import ECCMalfunctionException, \
MinerFailedToFetchMacAddress
from hm_pyhelper.lock_singleton import ResourceBusyError
from hm_pyhelper.miner_param import get_gateway_mfr_test_result, \
retry_get_region, await_spi_available, \
provision_key, \
did_gateway_mfr_test_result_include_miner_key_pass, \
get_mac_address
import unittest
from unittest.mock import mock_open, patch
Expand Down Expand Up @@ -177,3 +181,24 @@ def test_is_spi_available(self, _):
def test_error_mac_address(self):
with pytest.raises(MinerFailedToFetchMacAddress):
get_mac_address("test/path")

@patch(
'hm_pyhelper.miner_param.run_gateway_mfr',
side_effect=FileNotFoundError("File Not Found Error"))
def test_filenotfound_exception(self, mock):
with pytest.raises(FileNotFoundError):
get_gateway_mfr_test_result()

@patch(
'hm_pyhelper.miner_param.run_gateway_mfr',
side_effect=ECCMalfunctionException("File Not Found Error"))
def test_eccmalfunction_exception(self, mock):
with pytest.raises(ECCMalfunctionException):
get_gateway_mfr_test_result()

@patch(
'hm_pyhelper.miner_param.run_gateway_mfr',
side_effect=ResourceBusyError("Resource Busy Error"))
def test_resourcebusy_exception(self, mock):
with pytest.raises(ResourceBusyError):
get_gateway_mfr_test_result()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='hm_pyhelper',
version='0.11.7',
version='0.11.8',
author="Nebra Ltd",
author_email="[email protected]",
description="Helium Python Helper",
Expand Down

0 comments on commit ddd2943

Please sign in to comment.