From a83387f7a1a28c8e1db5697d03203e622eb24530 Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Thu, 12 Dec 2024 09:35:14 +0000 Subject: [PATCH] Add initial integration tests for the Client class Unfortunately, one of the two tests is just an example of what we would expect to work later: We cannot post incidents to Argus as the admin user, we have to create a source system and a user/token combo for that source system first. --- tests/test_client.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/test_client.py diff --git a/tests/test_client.py b/tests/test_client.py new file mode 100644 index 0000000..63b9912 --- /dev/null +++ b/tests/test_client.py @@ -0,0 +1,35 @@ +from collections.abc import Iterable +from datetime import datetime + +import pytest + +from pyargus.client import Client +from pyargus.models import Incident + + +class TestApiIntegration: + def test_incidents_list_should_return_iterable(self, api_client): + incidents = api_client.get_incidents() + assert isinstance(incidents, Iterable) + + @pytest.mark.xfail( + reason="We must add a source system to Argus to do this properly" + ) + def test_when_posting_incident_it_should_return_full_incident(self, api_client): + post = Incident( + description="The earth was demolished to make way for a hyperspace bypass", + start_time=datetime.now(), + tags={ + "host": "earth.example.org", + }, + ) + result = api_client.post_incident(post) + assert isinstance(result, Incident) + assert result.description == post.description + assert result.pk + + +@pytest.fixture +def api_client(argus_api): + url, token = argus_api + return Client(url, token)