Skip to content

Commit 26b2650

Browse files
committed
style: use single quotation marks in the code
1 parent 73ae97b commit 26b2650

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

hathor/healthcheck/models.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
class ComponentType(str, Enum):
99
"""Enum used to store the component types that can be used in the HealthCheckComponentStatus class."""
1010

11-
DATASTORE = "datastore"
12-
INTERNAL = "internal"
13-
FULLNODE = "fullnode"
11+
DATASTORE = 'datastore'
12+
INTERNAL = 'internal'
13+
FULLNODE = 'fullnode'
1414

1515

1616
class HealthCheckStatus(str, Enum):
1717
"""Enum used to store the component status that can be used in the HealthCheckComponentStatus class."""
1818

19-
PASS = "pass"
20-
WARN = "warn"
21-
FAIL = "fail"
19+
PASS = 'pass'
20+
WARN = 'warn'
21+
FAIL = 'fail'
2222

2323

2424
@dataclass
@@ -35,29 +35,29 @@ class ComponentHealthCheck:
3535
observed_unit: Optional[str] = None
3636

3737
def __post_init__(self) -> None:
38-
self.time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
38+
self.time = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
3939

4040
def to_json(self) -> dict[str, str]:
4141
"""Return a dict representation of the object. All field names are converted to camel case."""
4242
json = {
43-
"componentType": self.component_type.value,
44-
"status": self.status.value,
45-
"output": self.output,
43+
'componentType': self.component_type.value,
44+
'status': self.status.value,
45+
'output': self.output,
4646
}
4747

4848
if self.time:
49-
json["time"] = self.time
49+
json['time'] = self.time
5050

5151
if self.component_id:
52-
json["componentId"] = self.component_id
52+
json['componentId'] = self.component_id
5353

5454
if self.observed_value:
5555
assert (
5656
self.observed_unit is not None
57-
), "observed_unit must be set if observed_value is set"
57+
), 'observed_unit must be set if observed_value is set'
5858

59-
json["observedValue"] = self.observed_value
60-
json["observedUnit"] = self.observed_unit
59+
json['observedValue'] = self.observed_value
60+
json['observedUnit'] = self.observed_unit
6161

6262
return json
6363

@@ -71,7 +71,7 @@ class ServiceHealthCheck:
7171

7272
@property
7373
def status(self) -> HealthCheckStatus:
74-
"Return the status of the health check based on the status of the components."
74+
"""Return the status of the health check based on the status of the components."""
7575
status = HealthCheckStatus.PASS
7676

7777
for component_checks in self.checks.values():
@@ -87,7 +87,7 @@ def __post_init__(self) -> None:
8787
"""Perform some validations after the object is initialized."""
8888
# Make sure the checks dict is not empty
8989
if not self.checks:
90-
raise ValueError("checks dict cannot be empty")
90+
raise ValueError('checks dict cannot be empty')
9191

9292
def get_http_status_code(self) -> int:
9393
"""Return the HTTP status code for the status."""
@@ -96,14 +96,14 @@ def get_http_status_code(self) -> int:
9696
elif self.status in [HealthCheckStatus.WARN, HealthCheckStatus.FAIL]:
9797
return 503
9898
else:
99-
raise ValueError(f"Missing treatment for status {self.status}")
99+
raise ValueError(f'Missing treatment for status {self.status}')
100100

101101
def to_json(self) -> dict[str, Any]:
102102
"""Return a dict representation of the object. All field names are converted to camel case."""
103103
return {
104-
"status": self.status.value,
105-
"description": self.description,
106-
"checks": {k: [c.to_json() for c in v] for k, v in self.checks.items()},
104+
'status': self.status.value,
105+
'description': self.description,
106+
'checks': {k: [c.to_json() for c in v] for k, v in self.checks.items()},
107107
}
108108

109109

hathor/healthcheck/resources/healthcheck.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ def build_sync_health_status(manager: HathorManager) -> ComponentHealthCheck:
1111
healthy, reason = manager.is_sync_healthy()
1212

1313
return ComponentHealthCheck(
14-
component_name="sync",
14+
component_name='sync',
1515
component_type=ComponentType.INTERNAL,
1616
status=HealthCheckStatus.PASS if healthy else HealthCheckStatus.FAIL,
17-
output=reason or "Healthy",
17+
output=reason or 'Healthy',
1818
)
1919

2020

@@ -43,7 +43,7 @@ def render_GET(self, request):
4343
]
4444

4545
health_check = ServiceHealthCheck(
46-
description=f"Hathor-core {hathor.__version__}",
46+
description=f'Hathor-core {hathor.__version__}',
4747
checks={c.component_name: [c] for c in components_health_checks},
4848
)
4949

tests/resources/healthcheck/test_healthcheck.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setUp(self):
2121
def test_get_no_recent_activity(self):
2222
"""Scenario where the node doesn't have a recent block
2323
"""
24-
response = yield self.web.get("/health")
24+
response = yield self.web.get('/health')
2525
data = response.json_value()
2626

2727
self.assertEqual(response.responseCode, 503)
@@ -43,7 +43,7 @@ def test_strict_status_code(self):
4343
"""Make sure the 'strict_status_code' parameter is working.
4444
The node should return 200 even if it's not ready.
4545
"""
46-
response = yield self.web.get("/health", {b'strict_status_code': b'1'})
46+
response = yield self.web.get('/health', {b'strict_status_code': b'1'})
4747
data = response.json_value()
4848

4949
self.assertEqual(response.responseCode, 200)
@@ -69,7 +69,7 @@ def test_get_no_connected_peer(self):
6969

7070
self.assertEqual(self.manager.has_recent_activity(), True)
7171

72-
response = yield self.web.get("/health")
72+
response = yield self.web.get('/health')
7373
data = response.json_value()
7474

7575
self.assertEqual(response.responseCode, 503)
@@ -101,7 +101,7 @@ def test_get_peer_out_of_sync(self):
101101

102102
self.assertEqual(self.manager2.state, self.manager2.NodeState.READY)
103103

104-
response = yield self.web.get("/health")
104+
response = yield self.web.get('/health')
105105
data = response.json_value()
106106

107107
self.assertEqual(response.responseCode, 503)
@@ -133,7 +133,7 @@ def test_get_ready(self):
133133
self.conn1.run_one_step(debug=True)
134134
self.clock.advance(0.1)
135135

136-
response = yield self.web.get("/health")
136+
response = yield self.web.get('/health')
137137
data = response.json_value()
138138

139139
self.assertEqual(response.responseCode, 200)

0 commit comments

Comments
 (0)