File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,8 @@ def __init__(
2424 self .response = response
2525 self .detail = detail
2626 self .headers = headers
27+ super ().__init__ (self .response )
2728
2829 def __repr__ (self ) -> str :
2930 class_name = self .__class__ .__name__
30- return f"{ class_name } (status_code ={ self .status_code !r} , detail= { self . detail !r } ) "
31+ return f"{ class_name } (response ={ self .response !r} "
Original file line number Diff line number Diff line change 1+ {
2+ "status" : 422 ,
3+ "error" : " Unprocessable Entity" ,
4+ "code" : " validation_errors" ,
5+ "error_details" : { "transaction_id" : [" value_already_exist" ] }
6+ }
Original file line number Diff line number Diff line change @@ -45,6 +45,14 @@ def mock_response():
4545 return event_response .read ()
4646
4747
48+ def mock_unprocessable_entity_response ():
49+ this_dir = os .path .dirname (os .path .abspath (__file__ ))
50+ data_path = os .path .join (this_dir , "fixtures/event_unprocessable_entity.json" )
51+
52+ with open (data_path , "rb" ) as unprocessable_entity_response :
53+ return unprocessable_entity_response .read ()
54+
55+
4856def mock_fees_response ():
4957 this_dir = os .path .dirname (os .path .abspath (__file__ ))
5058 data_path = os .path .join (this_dir , "fixtures/fees.json" )
@@ -68,13 +76,13 @@ def test_valid_create_events_request_with_string_timestamp(httpx_mock: HTTPXMock
6876
6977
7078def test_invalid_create_events_request (httpx_mock : HTTPXMock ):
71- client = Client (api_key = "invalid " )
79+ client = Client (api_key = "886fe239-927d-4072-ab72-6dd345e8dd0d " )
7280
7381 httpx_mock .add_response (
7482 method = "POST" ,
7583 url = "https://api.getlago.com/api/v1/events" ,
76- status_code = 401 ,
77- content = b"" ,
84+ status_code = 422 ,
85+ content = mock_unprocessable_entity_response () ,
7886 )
7987
8088 with pytest .raises (LagoApiError ):
You can’t perform that action at this time.
0 commit comments