Skip to content

Commit

Permalink
Fix op5, needed post in the end
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Sep 8, 2022
1 parent 071eecb commit e4ad7ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pytroll_monitor/monitor_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def send_message(self, status, msg):
"service_description": self.monitor_service,
"status_code": status,
"plugin_output": msg}
with requests.get(self.monitor_server,
with requests.post(self.monitor_server,
auth=self.monitor_auth,
json=json_data) as response:
response.raise_for_status()
Expand Down
8 changes: 4 additions & 4 deletions pytroll_monitor/tests/test_op5.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ def test_op5monitor_without_auth(self):
op5m = OP5Monitor(self.service, self.server, self.host, monitor_auth=None)

with requests_mock.Mocker() as m:
m.get(self.server, text=self.response_text)
m.post(self.server, text=self.response_text)
op5m.send_message(self.status, self.message)
assert m.last_request.json() == self.expected_json
assert m.last_request.url == self.server
assert m.last_request.method == "GET"
assert m.last_request.method == "POST"
assert "Authorization" not in m.last_request.headers

def test_op5monitor_with_auth(self):
"""Test the monitor with authentication."""
op5m = OP5Monitor(self.service, self.server, self.host, self.auth)

with requests_mock.Mocker() as m:
m.get(self.server, text=self.response_text)
m.post(self.server, text=self.response_text)
op5m.send_message(self.status, self.message)
assert m.last_request.headers["Authorization"] == self.expected_auth

Expand All @@ -74,7 +74,7 @@ def test_op5handler(self):
logging.config.dictConfig(log_dict)

with requests_mock.Mocker() as m:
m.get(self.server, text=self.response_text)
m.post(self.server, text=self.response_text)
logger.warning(self.message)
assert m.last_request.json() == self.expected_json
assert m.last_request.headers["Authorization"] == self.expected_auth

0 comments on commit e4ad7ea

Please sign in to comment.