Test successful OpenAPI export.
(self, mock_makedirs, mock_file, mock_app)
| 20 | @patch("builtins.open", new_callable=mock_open) |
| 21 | @patch("os.makedirs") |
| 22 | def test_export_openapi_success(self, mock_makedirs, mock_file, mock_app): |
| 23 | """Test successful OpenAPI export.""" |
| 24 | mock_openapi_data = {"openapi": "3.0.0", "info": {"title": "Test API"}} |
| 25 | mock_app.return_value.openapi.return_value = mock_openapi_data |
| 26 | |
| 27 | result = export_openapi("/test/path/openapi.json") |
| 28 | |
| 29 | assert result is True |
| 30 | mock_makedirs.assert_called_once_with("/test/path", exist_ok=True) |
| 31 | mock_file.assert_called_once_with("/test/path/openapi.json", "w") |
| 32 | |
| 33 | @patch("memos.cli.get_openapi_app") |
| 34 | @patch("builtins.open", side_effect=OSError("Permission denied")) |
nothing calls this directly
no test coverage detected