Skip to content

Commit

Permalink
Merge branch 'feature/unit-test-error' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
boobooboo2 committed Dec 19, 2024
2 parents 8e939a7 + d1fb904 commit 4dd7d4b
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_test_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_usage_examples/env_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

while True:
print(f"humidity(%): {env.humidity:<10} temperature(°C): {env.temperature:<10} "
f"intensity(%): {env.intensity:<10} Volume(%): {env.volume:<10}", end="\r")
f"illuminance(%): {env.illuminance:<10} Volume(%): {env.volume:<10}", end="\r")
time.sleep(0.02)
4 changes: 2 additions & 2 deletions modi_plus/module/input_module/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Env(InputModule):

PROPERTY_ENV_STATE = 2

PROPERTY_OFFSET_INTENSICY = 0
PROPERTY_OFFSET_ILLUMINANCE = 0
PROPERTY_OFFSET_TEMPERATURE = 2
PROPERTY_OFFSET_HUMIDITY = 4
PROPERTY_OFFSET_VOLUME = 6
Expand All @@ -21,7 +21,7 @@ def illuminance(self) -> int:
:rtype: int
"""

offset = Env.PROPERTY_OFFSET_INTENSICY
offset = Env.PROPERTY_OFFSET_ILLUMINANCE
raw = self._get_property(Env.PROPERTY_ENV_STATE)
data = struct.unpack("h", raw[offset:offset + 2])[0]
return data
Expand Down
2 changes: 1 addition & 1 deletion modi_plus/module/input_module/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def angle(self) -> Tuple[float, float, float]:
:rtype: tuple
"""

return self.angle_x, self.angle_y_y, self.angle_z
return self.angle_x, self.angle_y, self.angle_z

@property
def angular_vel_x(self) -> float:
Expand Down
6 changes: 4 additions & 2 deletions modi_plus/module/output_module/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ def set_angle(self, target_angle: int, target_speed: int = 70) -> None:
:return: None
"""

if (target_angle < 0 or target_angle > 360)\
or (target_speed < 0 or target_speed > 100):
invalid_angle = (target_angle < 0 or target_angle > 360)
invalid_speed = (target_speed < 0 or target_speed > 100)

if invalid_angle or invalid_speed:
return

self._set_property(
Expand Down
18 changes: 9 additions & 9 deletions modi_plus/module/setup_module/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ def time_up(self) -> bool:

@property
@check_connection
def imu_angle_x(self) -> int:
"""Returns the angle_x angle of the MODI Play imu
def imu_roll(self) -> int:
"""Returns the roll angle of the MODI Play imu
:return: Angle_x angle.
:return: Roll angle.
:rtype: int
"""

Expand All @@ -261,10 +261,10 @@ def imu_angle_x(self) -> int:

@property
@check_connection
def imu_angle_y(self) -> int:
"""Returns the angle_y angle of the MODI Play imu
def imu_pitch(self) -> int:
"""Returns the pitch angle of the MODI Play imu
:return: Angle_y angle.
:return: Pitch angle.
:rtype: int
"""

Expand All @@ -277,10 +277,10 @@ def imu_angle_y(self) -> int:

@property
@check_connection
def imu_angle_zle_z(self) -> int:
"""Returns the angle_z angle of the MODI Play imu
def imu_yaw(self) -> int:
"""Returns the yaw angle of the MODI Play imu
:return: Angle_z angle.
:return: Yaw angle.
:rtype: int
"""

Expand Down
6 changes: 3 additions & 3 deletions tests/module/input_module/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def test_get_humidity(self):
)
self.assertEqual(_, 0)

def test_get_intensity(self):
"""Test get_intensity method."""
def test_get_illuminance(self):
"""Test get_illuminance method."""

_ = self.env.intensity
_ = self.env.illuminance
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Env.PROPERTY_ENV_STATE, self.env.prop_samp_freq)
Expand Down
5 changes: 4 additions & 1 deletion tests/module/output_module/test_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def test_set_angle(self):
self.motor.angle = mock_angle, mock_speed
set_message = parse_set_property_message(
-1, Motor.PROPERTY_MOTOR_ANGLE,
(("u16", mock_angle), ("u16", mock_speed), )
(("u16", mock_angle),
("u16", mock_speed),
("u16", 0),
("u16", 0), )
)
sent_messages = []
while self.connection.send_list:
Expand Down
18 changes: 9 additions & 9 deletions tests/module/setup_module/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,30 @@ def test_time_up(self):
)
self.assertEqual(_, False)

def test_imu_angle_x(self):
"""Test imu_angle_x method."""
def test_imu_roll(self):
"""Test imu_roll method."""

_ = self.network.imu_angle_x
_ = self.network.imu_roll
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Network.PROPERTY_NETWORK_IMU, self.network.prop_samp_freq)
)
self.assertEqual(_, 0)

def test_imu_angle_y(self):
"""Test imu_angle_y method."""
def test_imu_pitch(self):
"""Test imu_pitch method."""

_ = self.network.imu_angle_y
_ = self.network.imu_pitch
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Network.PROPERTY_NETWORK_IMU, self.network.prop_samp_freq)
)
self.assertEqual(_, 0)

def test_imu_angle_z(self):
"""Test imu_angle_z method."""
def test_imu_yaw(self):
"""Test imu_yaw method."""

_ = self.network.imu_angle_z
_ = self.network.imu_yaw
self.assertEqual(
self.connection.send_list[0],
parse_get_property_message(-1, Network.PROPERTY_NETWORK_IMU, self.network.prop_samp_freq)
Expand Down

0 comments on commit 4dd7d4b

Please sign in to comment.