Skip to content

Commit

Permalink
Fixed loading latency_unit from configuration
Browse files Browse the repository at this point in the history
Fixes #89
  • Loading branch information
nijel committed Apr 29, 2020
1 parent 21063d6 commit 19fc8c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cachet_url_monitor/configuration.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, config, endpoint_index: int, client: CachetClient, token: str
self.default_metric_value = self.client.get_default_metric_value(self.metric_id)

# The latency_unit configuration is not mandatory and we fallback to seconds, by default.
self.latency_unit = self.data['cachet'].get('latency_unit') or 's'
self.latency_unit = self.endpoint.get('latency_unit') or 's'

# We need the current status so we monitor the status changes. This is necessary for creating incidents.
self.status = self.client.get_component_status(self.component_id)
Expand Down
1 change: 1 addition & 0 deletions tests/test_configuration.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_init(configuration):
assert len(configuration.expectations) == 3, 'Number of expectations read from file is incorrect'
assert configuration.headers == {'X-Cachet-Token': 'token2'}, 'Header was not set correctly'
assert configuration.endpoint_header == {'SOME-HEADER': 'SOME-VALUE'}, 'Header is incorrect'
assert configuration.latency_unit == 'ms'


def test_init_unknown_status(config_file, mock_client):
Expand Down

0 comments on commit 19fc8c9

Please sign in to comment.