2424# Reusable Mock Helpers
2525# =======================
2626
27+
2728class MockContent :
2829 """Reusable mock content class for Anthropic responses."""
30+
2931 def __init__ (self , text = "Bar" , content_type = "text" ):
3032 self .type = content_type
3133 self .text = text
3234
3335
3436class MockUsage :
3537 """Reusable mock usage class for Anthropic responses."""
36- def __init__ (self , input_tokens = 18 , output_tokens = 1 , cache_read_input_tokens = 0 , cache_creation_input_tokens = 0 ):
38+
39+ def __init__ (
40+ self ,
41+ input_tokens = 18 ,
42+ output_tokens = 1 ,
43+ cache_read_input_tokens = 0 ,
44+ cache_creation_input_tokens = 0 ,
45+ ):
3746 self .input_tokens = input_tokens
3847 self .output_tokens = output_tokens
3948 self .cache_read_input_tokens = cache_read_input_tokens
@@ -42,15 +51,23 @@ def __init__(self, input_tokens=18, output_tokens=1, cache_read_input_tokens=0,
4251
4352class MockResponse :
4453 """Reusable mock response class for Anthropic messages."""
45- def __init__ (self , content_text = "Bar" , model = "claude-3-opus-20240229" ,
46- input_tokens = 18 , output_tokens = 1 , cache_read = 0 , cache_creation = 0 ):
54+
55+ def __init__ (
56+ self ,
57+ content_text = "Bar" ,
58+ model = "claude-3-opus-20240229" ,
59+ input_tokens = 18 ,
60+ output_tokens = 1 ,
61+ cache_read = 0 ,
62+ cache_creation = 0 ,
63+ ):
4764 self .content = [MockContent (text = content_text )]
4865 self .model = model
4966 self .usage = MockUsage (
5067 input_tokens = input_tokens ,
5168 output_tokens = output_tokens ,
5269 cache_read_input_tokens = cache_read ,
53- cache_creation_input_tokens = cache_creation
70+ cache_creation_input_tokens = cache_creation ,
5471 )
5572
5673
@@ -62,6 +79,7 @@ def create_mock_response(**kwargs):
6279# Streaming mock helpers
6380class MockStreamEvent :
6481 """Reusable mock event class for streaming responses."""
82+
6583 def __init__ (self , event_type = None , ** kwargs ):
6684 self .type = event_type
6785 for key , value in kwargs .items ():
@@ -70,6 +88,7 @@ def __init__(self, event_type=None, **kwargs):
7088
7189class MockContentBlock :
7290 """Reusable mock content block for streaming."""
91+
7392 def __init__ (self , block_type , ** kwargs ):
7493 self .type = block_type
7594 for key , value in kwargs .items ():
@@ -78,6 +97,7 @@ def __init__(self, block_type, **kwargs):
7897
7998class MockDelta :
8099 """Reusable mock delta for streaming events."""
100+
81101 def __init__ (self , ** kwargs ):
82102 for key , value in kwargs .items ():
83103 setattr (self , key , value )
0 commit comments