Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bewegungsschrift.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import yaml
import cv2
from microservices import video_input, pose_estimation, human_selection, labanotation_generation
from microservices.pose_estimation.perform_pose_estimation import launch_webcam_test
from microservices.pose_estimation.launch_webcam_cube_test import launch_webcam_cube_test
Expand Down
9 changes: 9 additions & 0 deletions tests/test_bewegungsschrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,14 @@ def test_main_with_human_selection(self, mock_parse_args):
mock_generate_labanotation.assert_called_once_with(['pose1', 'pose2'])
mock_save_labanotation.assert_called_once_with('labanotation', 'output.yaml')

@patch('bewegungsschrift.argparse.ArgumentParser.parse_args')
def test_main_with_webcam_cube_logging(self, mock_parse_args):
mock_parse_args.return_value = MagicMock(webcam_cube=True, input=None, output=None, select_human=False)
with patch('bewegungsschrift.pose_estimation.launch_webcam_cube_test') as mock_launch_webcam_cube_test, \
patch('builtins.print') as mock_print:
bewegungsschrift.main()
mock_launch_webcam_cube_test.assert_called_once()
mock_print.assert_any_call("Human position in 3D cube: {'x': 0.5, 'y': 0.5, 'z': 0.0}")

if __name__ == '__main__':
unittest.main()
25 changes: 25 additions & 0 deletions tests/test_perform_pose_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,30 @@ def test_perform_pose_estimation(self, mock_process):
pose_estimations = perform_pose_estimation.perform_pose_estimation(frames)
self.assertEqual(pose_estimations, expected_pose_estimations)

@patch('microservices.pose_estimation.launch_webcam_cube_test.cv2.VideoCapture')
@patch('microservices.pose_estimation.launch_webcam_cube_test.mp.solutions.holistic.Holistic.process')
@patch('microservices.pose_estimation.launch_webcam_cube_test.cv2.imshow')
@patch('microservices.pose_estimation.launch_webcam_cube_test.cv2.waitKey', return_value=27)
@patch('microservices.pose_estimation.launch_webcam_cube_test.cv2.destroyAllWindows')
def test_launch_webcam_cube_test(self, mock_destroyAllWindows, mock_waitKey, mock_imshow, mock_process, mock_VideoCapture):
mock_cap = MagicMock()
mock_VideoCapture.return_value = mock_cap
mock_cap.isOpened.side_effect = [True, False]
mock_cap.read.return_value = (True, 'frame')

mock_results = MagicMock()
mock_results.pose_landmarks = MagicMock()
mock_results.pose_landmarks.landmark = [MagicMock(x=0.5, y=0.5, z=0.0)]
mock_process.return_value = mock_results

perform_pose_estimation.launch_webcam_cube_test()

mock_VideoCapture.assert_called_once_with(0)
mock_cap.read.assert_called_once()
mock_process.assert_called_once()
mock_imshow.assert_called_once_with('Webcam Cube Test', 'frame')
mock_waitKey.assert_called_once_with(5)
mock_destroyAllWindows.assert_called_once()

if __name__ == '__main__':
unittest.main()