From 210998351f8940c2a66209243043351e4ea62a57 Mon Sep 17 00:00:00 2001 From: josep Date: Thu, 19 Dec 2024 09:51:02 +0900 Subject: [PATCH] =?UTF-8?q?unit=20test=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=951?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/basic_usage_examples/env_example.py | 2 +- modi_plus/module/input_module/env.py | 4 ++-- modi_plus/module/input_module/imu.py | 2 +- tests/module/input_module/test_env.py | 6 +++--- tests/module/output_module/test_motor.py | 5 ++++- tests/module/setup_module/test_network.py | 18 +++++++++--------- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/examples/basic_usage_examples/env_example.py b/examples/basic_usage_examples/env_example.py index 20e8563..866f207 100644 --- a/examples/basic_usage_examples/env_example.py +++ b/examples/basic_usage_examples/env_example.py @@ -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) diff --git a/modi_plus/module/input_module/env.py b/modi_plus/module/input_module/env.py index 8eb16b2..1569d03 100644 --- a/modi_plus/module/input_module/env.py +++ b/modi_plus/module/input_module/env.py @@ -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 @@ -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 diff --git a/modi_plus/module/input_module/imu.py b/modi_plus/module/input_module/imu.py index b5a5dbe..c469a76 100644 --- a/modi_plus/module/input_module/imu.py +++ b/modi_plus/module/input_module/imu.py @@ -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: diff --git a/tests/module/input_module/test_env.py b/tests/module/input_module/test_env.py index 811ba8b..14a7369 100644 --- a/tests/module/input_module/test_env.py +++ b/tests/module/input_module/test_env.py @@ -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) diff --git a/tests/module/output_module/test_motor.py b/tests/module/output_module/test_motor.py index d57c8f4..0e6c15c 100644 --- a/tests/module/output_module/test_motor.py +++ b/tests/module/output_module/test_motor.py @@ -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: diff --git a/tests/module/setup_module/test_network.py b/tests/module/setup_module/test_network.py index aa7abc3..7a7f7ca 100644 --- a/tests/module/setup_module/test_network.py +++ b/tests/module/setup_module/test_network.py @@ -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)