Spaces:
Sleeping
Sleeping
| import sys | |
| import os | |
| sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) | |
| import numpy as np | |
| import cv2 | |
| from draft_computation_app import calculate_draft | |
| from draft_computation_app.dummy_data import results2 as results | |
| def test_calculate_draft(): | |
| pose_results = results.pose | |
| segment_data = results.segment | |
| # Load the test image | |
| image_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "dummy_data", "test2.jpg") | |
| original_image = cv2.imread(image_path) | |
| # Set the ocr placeholder to return a specific value for the test | |
| from draft_computation_app import ocr_placeholder | |
| ocr_placeholder.perform_ocr = lambda image: "12m" | |
| draft = calculate_draft(pose_results, segment_data, original_image) | |
| print(f"The calculated draft is: {draft}") | |
| # Add an assertion to check if the result is within a reasonable range | |
| # This expected value is just a placeholder and should be adjusted | |
| # based on the actual expected output. | |
| expected_draft = 11.41 | |
| assert abs(draft - expected_draft) < 0.1 | |
| if __name__ == "__main__": | |
| test_calculate_draft() | |