Skip to content

Commit

Permalink
fix: failing tests and linters
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed Oct 10, 2023
1 parent 494128a commit e69ad41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions scripts/check_doc_ipfs_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ def get_packages_from_repository(repo_url: str) -> Dict[str, str]:
)

response = requests.get(url)

if response.status_code == 200:
data = response.json()
if "dev" in data:
return {**data["dev"], **data["third_party"]}
return data
else:
raise Exception(f"Failed to fetch data from URL: {url}")

raise Exception(f"Failed to fetch data from URL: {url}")


class Package: # pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -151,11 +150,10 @@ def __init__(
if "version" in resource:
self.last_version = resource["version"]
break
except Exception:
except Exception: # pylint: disable=broad-except
if not self.ignore_file_load_errors:
raise
else:
self.last_version = self.package_id.version
self.last_version = self.package_id.version

def get_command(
self, cmd: str, include_version: bool = True, flags: str = ""
Expand Down
14 changes: 7 additions & 7 deletions tests/test_autonomy/test_cli/test_helpers/test_fsm_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)

import packages
from packages.valory.skills import hello_world_abci, test_abci
from packages.valory.skills import offend_abci, test_abci

from tests.conftest import ROOT_DIR

Expand Down Expand Up @@ -72,7 +72,7 @@ def test_import_and_validate_app_class_raises() -> None:
def test_update_one() -> None:
"""Test update_one"""

package_path = Path(hello_world_abci.__file__).parent.relative_to(ROOT_DIR)
package_path = Path(offend_abci.__file__).parent.relative_to(ROOT_DIR)
with mock.patch.object(FSMSpecificationLoader, "dump") as m:
update_one(package_path)
m.assert_called_once()
Expand All @@ -86,7 +86,7 @@ def test_update_one_raises() -> None:
with pytest.raises(ClickException, match=expected):
update_one(package_path)

package_path = Path(hello_world_abci.__file__).parent.relative_to(ROOT_DIR)
package_path = Path(offend_abci.__file__).parent.relative_to(ROOT_DIR)
expected = "Please provide name for the app class or make sure FSM specification file is properly defined."
with mock.patch.object(FSMSpecificationLoader, "load", return_value={}):
with pytest.raises(ValueError, match=expected):
Expand All @@ -96,28 +96,28 @@ def test_update_one_raises() -> None:
def test_check_one() -> None:
"""Test check_one"""

package_path = Path(hello_world_abci.__file__).parent.relative_to(ROOT_DIR)
package_path = Path(offend_abci.__file__).parent.relative_to(ROOT_DIR)
check_one(package_path)


def test_check_one_raises() -> None:
"""Test check_one raises"""

package_path = Path(hello_world_abci.__file__).parent.relative_to(ROOT_DIR)
package_path = Path(offend_abci.__file__).parent.relative_to(ROOT_DIR)

expected = "Please provide name for the app class or make sure FSM specification file is properly defined."
with mock.patch.object(FSMSpecificationLoader, "load", return_value={}):
with pytest.raises(ValueError, match=expected):
update_one(package_path)

expected = 'Class .* is not in "packages.valory.skills.hello_world_abci.rounds"'
expected = 'Class .* is not in "packages.valory.skills.offend_abci.rounds"'
with pytest.raises(ClickException, match=expected):
check_one(package_path, app_class="DummyAbciApp")

target = "autonomy.cli.helpers.fsm_spec.check_unreferenced_events"
with mock.patch(target, return_value=["Event.WIN_LOTTERY"]):
expected = (
"Unreferenced events found in `HelloWorldAbciApp`\n- Event.WIN_LOTTERY"
"Unreferenced events found in `OffendAbciApp`\n- Event.WIN_LOTTERY"
)
with pytest.raises(DFASpecificationError, match=expected):
check_one(package_path)
Expand Down

0 comments on commit e69ad41

Please sign in to comment.