Skip to content

Commit b12484a

Browse files
committed
refactor(test): remove unnecessary test
Signed-off-by: Shingo OKAWA <[email protected]>
1 parent f903658 commit b12484a

File tree

3 files changed

+897
-540
lines changed

3 files changed

+897
-540
lines changed

scripts/grpc_gen_post_processor.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""
2-
Fix absolute imports in *_pb2_grpc.py files.
1+
"""Fix absolute imports in *_pb2_grpc.py files.
2+
33
Example:
44
import a2a_pb2 as a2a__pb2
55
from . import a2a_pb2 as a2a__pb2
@@ -16,40 +16,40 @@ def process_generated_code(src_folder: str = 'src/a2a/grpc'):
1616
dir_path = Path(src_folder)
1717
print(dir_path)
1818
if not dir_path.is_dir():
19-
print('Source folder not found')
20-
sys.exit(1)
19+
print('Source folder not found')
20+
sys.exit(1)
2121

2222
grpc_pattern = '**/*_pb2_grpc.py'
2323
files = dir_path.glob(grpc_pattern)
2424

2525
for file in files:
26-
print(f'Processing {file}')
27-
try:
28-
with file.open('r', encoding='utf-8') as f:
29-
src_content = f.read()
30-
31-
# Change import a2a_pb2 as a2a__pb2
32-
import_pattern = r'^import (\w+_pb2) as (\w+__pb2)$'
33-
# to from . import a2a_pb2 as a2a__pb2
34-
replacement_pattern = r'from . import \1 as \2'
35-
36-
fixed_src_content = re.sub(
37-
import_pattern,
38-
replacement_pattern,
39-
src_content,
40-
flags=re.MULTILINE,
41-
)
42-
43-
if fixed_src_content != src_content:
44-
with file.open('w', encoding='utf-8') as f:
45-
f.write(fixed_src_content)
46-
print('Imports fixed')
47-
else:
48-
print('No changes needed')
49-
50-
except Exception as e:
51-
print(f'Error processing file {file}: {e}')
52-
sys.exit(1)
26+
print(f'Processing {file}')
27+
try:
28+
with file.open('r', encoding='utf-8') as f:
29+
src_content = f.read()
30+
31+
# Change import a2a_pb2 as a2a__pb2
32+
import_pattern = r'^import (\w+_pb2) as (\w+__pb2)$'
33+
# to from . import a2a_pb2 as a2a__pb2
34+
replacement_pattern = r'from . import \1 as \2'
35+
36+
fixed_src_content = re.sub(
37+
import_pattern,
38+
replacement_pattern,
39+
src_content,
40+
flags=re.MULTILINE,
41+
)
42+
43+
if fixed_src_content != src_content:
44+
with file.open('w', encoding='utf-8') as f:
45+
f.write(fixed_src_content)
46+
print('Imports fixed')
47+
else:
48+
print('No changes needed')
49+
50+
except Exception as e:
51+
print(f'Error processing file {file}: {e}')
52+
sys.exit(1)
5353

5454

5555
if __name__ == '__main__':

tests/server/apps/jsonrpc/test_jsonrpc_app.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@
1010
StarletteBaseUser = MagicMock() # type: ignore
1111

1212
from a2a.server.apps.jsonrpc.jsonrpc_app import (
13-
JSONRPCApplication, # Still needed for JSONRPCApplication default constructor arg
1413
StarletteUserProxy,
1514
)
16-
from a2a.server.request_handlers.request_handler import (
17-
RequestHandler, # For mock spec
18-
)
19-
from a2a.types import AgentCard # For mock spec
2015

2116

2217
# --- StarletteUserProxy Tests ---
@@ -55,33 +50,5 @@ def test_starlette_user_proxy_user_name_raises_attribute_error(self):
5550
_ = proxy.user_name
5651

5752

58-
# --- JSONRPCApplication Tests (Selected) ---
59-
60-
61-
class TestJSONRPCApplicationSetup: # Renamed to avoid conflict
62-
def test_jsonrpc_app_build_method_abstract_raises_typeerror(
63-
self,
64-
): # Renamed test
65-
mock_handler = MagicMock(spec=RequestHandler)
66-
# Mock agent_card with essential attributes accessed in JSONRPCApplication.__init__
67-
mock_agent_card = MagicMock(spec=AgentCard)
68-
# Ensure 'url' attribute exists on the mock_agent_card, as it's accessed in __init__
69-
mock_agent_card.url = 'http://mockurl.com'
70-
# Ensure 'supportsAuthenticatedExtendedCard' attribute exists
71-
mock_agent_card.supportsAuthenticatedExtendedCard = False
72-
73-
class AbstractTester(JSONRPCApplication):
74-
# No 'build' method implemented
75-
pass
76-
77-
# Instantiating an ABC subclass that doesn't implement all abstract methods raises TypeError
78-
with pytest.raises(
79-
TypeError,
80-
match="Can't instantiate abstract class AbstractTester with abstract method build",
81-
):
82-
# Using positional arguments for the abstract class constructor
83-
AbstractTester(mock_handler, mock_agent_card)
84-
85-
8653
if __name__ == '__main__':
8754
pytest.main([__file__])

0 commit comments

Comments
 (0)