1- import pytest
2- from unittest .mock import patch , mock_open
31import os
2+ from unittest .mock import patch
3+
4+ import pytest
45
56from src .config import SharePointConfig
67
@@ -25,8 +26,14 @@ def test_missing_required_env_vars(self):
2526 validation_errors = config .validate ()
2627
2728 assert len (validation_errors ) > 0
28- assert any ("SHAREPOINT_TENANT_ID is required" in error for error in validation_errors )
29- assert any ("SHAREPOINT_CLIENT_ID is required" in error for error in validation_errors )
29+ assert any (
30+ "SHAREPOINT_TENANT_ID is required" in error
31+ for error in validation_errors
32+ )
33+ assert any (
34+ "SHAREPOINT_CLIENT_ID is required" in error
35+ for error in validation_errors
36+ )
3037
3138 def test_certificate_text_priority_over_file (self ):
3239 """証明書テキストがファイルパスより優先されることのテスト"""
@@ -82,7 +89,9 @@ def test_default_values(self):
8289
8390 assert config .default_max_results == 20
8491 assert "pdf" in config .allowed_file_extensions
85- assert "Search for documents in SharePoint" in config .search_tool_description
92+ assert (
93+ "Search for documents in SharePoint" in config .search_tool_description
94+ )
8695 assert "Download a file from SharePoint" in config .download_tool_description
8796
8897 @pytest .mark .unit
@@ -119,16 +128,19 @@ def test_parse_onedrive_paths_basic(self):
119128 targets = config .parse_onedrive_paths ()
120129
121130 assert len (targets ) == 2
122-
131+
123132 # user1@company.com(フォルダー指定なし)
124133 assert targets [0 ]["email" ] == "user1@company.com"
125134 assert targets [0 ]["folder_path" ] == ""
126135 assert targets [0 ]["onedrive_path" ] == "personal/user1_company_com"
127-
136+
128137 # user2@company.com:/Documents/Projects
129138 assert targets [1 ]["email" ] == "user2@company.com"
130139 assert targets [1 ]["folder_path" ] == "/Documents/Projects"
131- assert targets [1 ]["onedrive_path" ] == "personal/user2_company_com/Documents/Projects"
140+ assert (
141+ targets [1 ]["onedrive_path" ]
142+ == "personal/user2_company_com/Documents/Projects"
143+ )
132144
133145 def test_parse_onedrive_paths_empty (self ):
134146 """OneDriveパス設定が空の場合のテスト"""
@@ -147,21 +159,23 @@ def test_parse_onedrive_paths_empty(self):
147159 def test_email_to_onedrive_path_conversion (self ):
148160 """メールアドレスからOneDriveパスへの変換テスト"""
149161 config = SharePointConfig ()
150-
162+
151163 # 基本的な変換
152164 path = config ._email_to_onedrive_path ("user@company.com" )
153165 assert path == "personal/user_company_com"
154-
166+
155167 # フォルダーパス付き
156168 path = config ._email_to_onedrive_path ("user@company.com" , "/Documents/Projects" )
157169 assert path == "personal/user_company_com/Documents/Projects"
158-
170+
159171 # 先頭スラッシュの除去
160172 path = config ._email_to_onedrive_path ("user@company.com" , "Documents/Projects" )
161173 assert path == "personal/user_company_com/Documents/Projects"
162-
174+
163175 # onmicrosoft.com ドメイン
164- path = config ._email_to_onedrive_path ("admin@company.onmicrosoft.com" , "/Documents" )
176+ path = config ._email_to_onedrive_path (
177+ "admin@company.onmicrosoft.com" , "/Documents"
178+ )
165179 assert path == "personal/admin_company_onmicrosoft_com/Documents"
166180
167181 def test_include_onedrive_property (self ):
@@ -359,7 +373,10 @@ def test_disable_multiple_tools(self):
359373 with patch .dict (os .environ , env_vars , clear = True ):
360374 config = SharePointConfig ()
361375
362- assert config .disabled_tools == {"sharepoint_excel" , "sharepoint_docs_download" }
376+ assert config .disabled_tools == {
377+ "sharepoint_excel" ,
378+ "sharepoint_docs_download" ,
379+ }
363380 assert config .is_tool_enabled ("sharepoint_docs_search" ) is True
364381 assert config .is_tool_enabled ("sharepoint_docs_download" ) is False
365382 assert config .is_tool_enabled ("sharepoint_excel" ) is False
@@ -416,6 +433,9 @@ def test_whitespace_handling(self):
416433 with patch .dict (os .environ , env_vars , clear = True ):
417434 config = SharePointConfig ()
418435
419- assert config .disabled_tools == {"sharepoint_excel" , "sharepoint_docs_download" }
436+ assert config .disabled_tools == {
437+ "sharepoint_excel" ,
438+ "sharepoint_docs_download" ,
439+ }
420440 assert config .is_tool_enabled ("sharepoint_excel" ) is False
421441 assert config .is_tool_enabled ("sharepoint_docs_download" ) is False
0 commit comments