Skip to content

Commit f6c6ef8

Browse files
Apply linting fixes to fault injector client
- Fixed whitespace in blank lines (W293) - Added trailing newline at end of file (W292) - Applied ruff formatting for consistent code style: * Improved line breaks for long function signatures * Consistent quote style (single to double quotes) * Proper parameter alignment and indentation All linting checks now pass: - ruff check: ✅ All checks passed - ruff format: ✅ Code properly formatted - vulture: ✅ No dead code detected
1 parent 50e66df commit f6c6ef8

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

tests/test_scenario/fault_injector_client.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,48 @@ def to_dict(self) -> Dict[str, str]:
2323

2424

2525
class ActionRequest:
26-
def __init__(self, action_type: ActionType, parameters: Union[Dict[str, Any], RestartDmcParams]):
26+
def __init__(
27+
self,
28+
action_type: ActionType,
29+
parameters: Union[Dict[str, Any], RestartDmcParams],
30+
):
2731
self.type = action_type
2832
self.parameters = parameters
2933

3034
def to_dict(self) -> Dict[str, Any]:
3135
return {
3236
"type": self.type.value, # Use the string value of the enum
33-
"parameters": self.parameters.to_dict() if isinstance(self.parameters,
34-
RestartDmcParams) else self.parameters
37+
"parameters": self.parameters.to_dict()
38+
if isinstance(self.parameters, RestartDmcParams)
39+
else self.parameters,
3540
}
3641

3742

3843
class FaultInjectorClient:
3944
def __init__(self, base_url: str):
40-
self.base_url = base_url.rstrip('/')
45+
self.base_url = base_url.rstrip("/")
4146

42-
def _make_request(self, method: str, path: str, data: Optional[Dict] = None) -> Dict[str, Any]:
47+
def _make_request(
48+
self, method: str, path: str, data: Optional[Dict] = None
49+
) -> Dict[str, Any]:
4350
url = f"{self.base_url}{path}"
4451
headers = {"Content-Type": "application/json"} if data else {}
4552

4653
request_data = None
4754
if data:
48-
request_data = json.dumps(data).encode('utf-8')
55+
request_data = json.dumps(data).encode("utf-8")
4956
print(f"JSON payload being sent: {request_data.decode('utf-8')}")
5057

5158
request = urllib.request.Request(
52-
url,
53-
method=method,
54-
data=request_data,
55-
headers=headers
59+
url, method=method, data=request_data, headers=headers
5660
)
5761

5862
try:
5963
with urllib.request.urlopen(request) as response:
60-
return json.loads(response.read().decode('utf-8'))
64+
return json.loads(response.read().decode("utf-8"))
6165
except urllib.error.HTTPError as e:
6266
if e.code == 422:
63-
error_body = json.loads(e.read().decode('utf-8'))
67+
error_body = json.loads(e.read().decode("utf-8"))
6468
raise ValueError(f"Validation Error: {error_body}")
6569
raise
6670

@@ -77,32 +81,31 @@ def trigger_action(self, action_request: ActionRequest) -> Dict[str, Any]:
7781
def get_action_status(self, action_id: str) -> Dict[str, Any]:
7882
"""Get the status of a specific action"""
7983
return self._make_request("GET", f"/action/{action_id}")
80-
81-
def execute_rladmin_command(self, command: str, bdb_id: str = None) -> Dict[str, Any]:
84+
85+
def execute_rladmin_command(
86+
self, command: str, bdb_id: str = None
87+
) -> Dict[str, Any]:
8288
"""Execute rladmin command directly as string"""
8389
url = f"{self.base_url}/rladmin"
84-
90+
8591
# The fault injector expects the raw command string
8692
command_string = f"rladmin {command}"
8793
if bdb_id:
8894
command_string = f"rladmin -b {bdb_id} {command}"
89-
95+
9096
print(f"Sending rladmin command: {command_string}")
91-
97+
9298
headers = {"Content-Type": "text/plain"}
93-
99+
94100
request = urllib.request.Request(
95-
url,
96-
method="POST",
97-
data=command_string.encode('utf-8'),
98-
headers=headers
101+
url, method="POST", data=command_string.encode("utf-8"), headers=headers
99102
)
100-
103+
101104
try:
102105
with urllib.request.urlopen(request) as response:
103-
return json.loads(response.read().decode('utf-8'))
106+
return json.loads(response.read().decode("utf-8"))
104107
except urllib.error.HTTPError as e:
105108
if e.code == 422:
106-
error_body = json.loads(e.read().decode('utf-8'))
109+
error_body = json.loads(e.read().decode("utf-8"))
107110
raise ValueError(f"Validation Error: {error_body}")
108-
raise
111+
raise

0 commit comments

Comments
 (0)