Skip to content

Commit

Permalink
Add initial integration tests for the Client class
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lunkwill42 committed Dec 12, 2024
1 parent 9f1ee22 commit a83387f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a83387f

Please sign in to comment.