Skip to content

Commit

Permalink
Removed 'current_state_name' attribute from tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Sep 21, 2023
1 parent 83d9f6b commit d10f3d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

# opensourceleg
<h1>opensourceleg</h1>

[![Build status](https://github.com/imsenthur/opensourceleg/workflows/build/badge.svg?branch=master&event=push)](https://github.com/imsenthur/opensourceleg/actions?query=workflow%3Abuild)
[![Documentation Status](https://readthedocs.org/projects/opensourceleg/badge/?version=latest)](https://opensourceleg.readthedocs.io/en/latest/?badge=latest)
Expand All @@ -11,8 +11,10 @@
[![Security: bandit](https://img.shields.io/badge/security-bandit-green.svg)](https://github.com/PyCQA/bandit)
[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/imsenthur/opensourceleg/blob/master/.pre-commit-config.yaml)
[![License](https://img.shields.io/github/license/imsenthur/opensourceleg)](https://github.com/imsenthur/opensourceleg/blob/master/LICENSE)
![Coverage Report](assets/images/coverage.svg)
![Coverage Report](https://github.com/neurobionics/opensourceleg/blob/66ad4289ef9ba8701fac9337778f87b657286484/assets/images/coverage.svg)

An open-source software library for numerical computation, data acquisition, <br>and control of lower-limb robotic prostheses.

<img src="assets/images/banner.gif" width="800" title="Open-Source Leg">
<img src="https://github.com/neurobionics/opensourceleg/blob/66ad4289ef9ba8701fac9337778f87b657286484/assets/images/banner.gif" width="800" title="Open-Source Leg">

</div>
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[metadata]
description-file = README.md

[darglint]
# https://github.com/terrencepreilly/darglint
strictness = long
Expand Down
22 changes: 10 additions & 12 deletions tests/test_state_machine/test_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def criteria_test(data="test_data") -> bool:
and asserts the callback is called.
"""

callback_log = Logger(file_path="tests/test_state_machine/{}".format(data))
callback_log = Logger(file_path=f"tests/test_state_machine/{data}")
callback_log.set_stream_level(level="DEBUG")
callback_log.debug("Criteria was called")
return True
Expand All @@ -282,7 +282,7 @@ def criteria_test2(data="log_name") -> bool:
and asserts the callback is called.
"""

callback_log = Logger(file_path="tests/test_state_machine/{}".format(data))
callback_log = Logger(file_path=f"tests/test_state_machine/{data}")
callback_log.set_stream_level(level="DEBUG")
callback_log.debug("Criteria2 was called")
return False
Expand All @@ -295,7 +295,7 @@ def test_action(data="log_name") -> bool:
and asserts the callback is called.
"""

callback_log = Logger(file_path="tests/test_state_machine/{}".format(data))
callback_log = Logger(file_path=f"tests/test_state_machine/{data}")
callback_log.set_stream_level(level="DEBUG")
callback_log.debug("Action was called")
return True
Expand All @@ -317,7 +317,7 @@ def test_state_start(mock_time):
test_state_start.start(data="test_state_start")
assert test_state_start._time_entered == 1.0
assert criteria_test in test_state_start._entry_callbacks
with open("tests/test_state_machine/test_state_start.log", "r") as f:
with open("tests/test_state_machine/test_state_start.log") as f:
contents = f.read()
assert "DEBUG: Criteria was called" in contents

Expand All @@ -338,7 +338,7 @@ def test_state_stop(mock_time):
test_state_stop.stop(data="test_state_stop")
assert test_state_stop._time_exited == 1.0
assert criteria_test2 in test_state_stop._exit_callbacks
with open("tests/test_state_machine/test_state_stop.log", "r") as f:
with open("tests/test_state_machine/test_state_stop.log") as f:
contents = f.read()
assert "DEBUG: Criteria2 was called" in contents

Expand Down Expand Up @@ -627,7 +627,7 @@ def test_from_to_transition_call(mock_time):
)
from_to_transition_call.add_action(callback=test_action)
test = from_to_transition_call(data="test_from_to_transition_call", spoof=True)
with open("tests/test_state_machine/test_from_to_transition_call.log", "r") as f:
with open("tests/test_state_machine/test_from_to_transition_call.log") as f:
contents = f.read()
assert "DEBUG: Action was called" in contents
assert test == State(name="state2")
Expand All @@ -654,7 +654,7 @@ def test_from_to_transition_call(mock_time):
)
from_to_transition_call2.add_action(callback=test_action)
test1 = from_to_transition_call2(data="test_from_to_transition_call2")
with open("tests/test_state_machine/test_from_to_transition_call2.log", "r") as f:
with open("tests/test_state_machine/test_from_to_transition_call2.log") as f:
contents = f.read()
assert "DEBUG: Action was called" in contents
assert test1 == State(name="state2")
Expand All @@ -666,7 +666,7 @@ def test_from_to_transition_call(mock_time):
)
from_to_transition_call3.add_criteria(callback=criteria_test2)
test2 = from_to_transition_call3(data="test_from_to_transition_call3")
with open("tests/test_state_machine/test_from_to_transition_call3.log", "r") as f:
with open("tests/test_state_machine/test_from_to_transition_call3.log") as f:
contents = f.read()
assert "DEBUG: Criteria2 was called" in contents
assert test2 == State(name="state1")
Expand Down Expand Up @@ -797,7 +797,7 @@ def exit_callback_test(idle=Idle(), data="test_state_machine_update2"):
and asserts the callback is called.
"""

callback_log = Logger(file_path="tests/test_state_machine/{}".format(data))
callback_log = Logger(file_path=f"tests/test_state_machine/{data}")
callback_log.set_stream_level(level="DEBUG")
callback_log.debug("Exit callback was called")
return True
Expand Down Expand Up @@ -842,7 +842,7 @@ def test_state_machine_update():
)
test_state_machine_update._osl.log.set_stream_level(level="DEBUG")
test_state_machine_update.update(data="test_data")
with open("tests/test_state_machine/test_state_machine_update.log", "r") as f:
with open("tests/test_state_machine/test_state_machine_update.log") as f:
contents = f.read()
assert "DEBUG: Event isn't valid at state1" in contents
# Assert the for loop works properly
Expand Down Expand Up @@ -982,7 +982,6 @@ def test_state_machine_default_properties():
test_state_machine_dp = StateMachine()
assert test_state_machine_dp.current_state == Idle()
assert test_state_machine_dp.states == ["idle"]
assert test_state_machine_dp.current_state_name == "idle"
assert test_state_machine_dp.is_spoofing == False


Expand All @@ -1004,5 +1003,4 @@ def test_state_machine_non_default_properties():
test_state_machine_ndp._spoof = True
assert test_state_machine_ndp.current_state == State(name="state2")
assert test_state_machine_ndp.states == ["idle", "state1", "state2", "state3"]
assert test_state_machine_ndp.current_state_name == "state2"
assert test_state_machine_ndp.is_spoofing == True

0 comments on commit d10f3d5

Please sign in to comment.