@@ -89,33 +89,18 @@ def test_generate_svg(self):
8989 self .assertIn ("CustomName" , svg )
9090 self .assertIn ("output-inactive" , svg )
9191
92- @patch ('modapi.output.ModbusClient' )
93- @patch ('modapi.output.auto_detect_modbus_port' )
94- @patch ('flask.Flask' )
95- def test_create_output_app (self , mock_flask , mock_auto_detect , mock_modbus_client ):
92+ def test_create_output_app (self ):
9693 """Test output app creation"""
97- # Set up mocks
98- mock_app = MagicMock ()
99- mock_flask .return_value = mock_app
100- mock_auto_detect .return_value = '/dev/ttyUSB0'
101-
102- # Mock ModbusClient instance
103- mock_client_instance = MagicMock ()
104- mock_modbus_client .return_value = mock_client_instance
105-
106- # Test app creation
94+ # Test app creation with debug mode
10795 app = create_output_app (debug = True )
108- self .assertIsNotNone (app )
10996
110- # Verify Flask app was created
111- mock_flask .assert_called_once_with (__name__ )
112-
113- # Verify route was added with expected path
114- mock_app .route .assert_any_call ('/module/output/<int:channel>' )
97+ # Verify the app is a Flask app
98+ self .assertIsNotNone (app )
99+ self .assertEqual (app .name , 'modapi.output' )
115100
116- # Verify before_request and after_request handlers were added
117- mock_app . before_request . assert_called_once ( )
118- mock_app . after_request . assert_called_once ( )
101+ # Verify the route is registered
102+ url_rules = list ( app . url_map . iter_rules () )
103+ self . assertTrue ( any ( rule . rule == '/module/output/<int:channel>' for rule in url_rules ) )
119104
120105
121106if __name__ == '__main__' :
0 commit comments