From 48694f84383d41c680c397e4c528676fd0b72c6b Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Sun, 8 Feb 2026 00:18:31 -0300 Subject: [PATCH] Improve test assertions to verify field values Assert actual field values in test_get_plugins_success (plugin names and descriptions), test_get_subdomains_success (subdomain names and IP counts), and test_get_plugins_unauthorized (status code). Closes #41 --- tests/test_client.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index d72b8d8..11a27cb 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -193,6 +193,10 @@ def test_get_plugins_success(self, client_with_api_key): response = client_with_api_key.get_plugins() assert response.is_success() assert len(response.json()) == 2 + assert response.json()[0].name == "GrafanaOpenPlugin" + assert response.json()[0].description == "Grafana open instances" + assert response.json()[1].name == "MongoOpenPlugin" + assert response.json()[1].description == "MongoDB open instances" def test_get_plugins_unauthorized(self, client): res_json = {"error": "unauthorized"} @@ -200,6 +204,7 @@ def test_get_plugins_unauthorized(self, client): m.get(f"{client.base_url}/api/plugins", json=res_json, status_code=401) response = client.get_plugins() assert response.is_error() + assert response.status_code() == 401 class TestGetSubdomains: @@ -225,6 +230,10 @@ def test_get_subdomains_success(self, client): response = client.get_subdomains("example.com") assert response.is_success() assert len(response.json()) == 2 + assert response.json()[0].subdomain == "api.example.com" + assert response.json()[0].distinct_ips == 2 + assert response.json()[1].subdomain == "www.example.com" + assert response.json()[1].distinct_ips == 1 def test_get_subdomains_empty(self, client): with requests_mock.Mocker() as m: