Updated integration tests to not require exact match

This matches how we want clients to behave, they should ignore any extra fields that are sent in the response.
This commit is contained in:
Donkie
2024-01-16 21:21:49 +01:00
parent 7972f4d401
commit f8cc9f7eda
8 changed files with 183 additions and 151 deletions

View File

@@ -7,14 +7,11 @@ from typing import Any
import httpx
import pytest
from ..conftest import assert_lists_compatible
URL = "http://spoolman:8000"
def vendor_lists_equal(a: Iterable[dict[str, Any]], b: Iterable[dict[str, Any]]) -> bool:
"""Compare two lists of vendors where the order of the vendors is not guaranteed."""
return sorted(a, key=lambda x: x["id"]) == sorted(b, key=lambda x: x["id"])
@dataclass
class Fixture:
vendors: list[dict[str, Any]]
@@ -62,7 +59,7 @@ def test_find_all_vendors(vendors: Fixture):
# Verify
vendors_result = result.json()
assert vendor_lists_equal(vendors_result, vendors.vendors)
assert_lists_compatible(vendors_result, vendors.vendors)
def test_find_all_vendors_sort_asc(vendors: Fixture):