Fix tests to match decision service API and add filtering to non-streaming endpoint
- Update test mocks from _get_disliked_ids to _get_user_id_safe - Fix decision service test method names (clear_decision -> remove_decision, etc.) - Fix positional vs keyword arg assertion in set_decision test - Add decision_filter param to non-streaming listing_geojson endpoint
This commit is contained in:
parent
a2745c1478
commit
43f9d210fb
3 changed files with 26 additions and 7 deletions
|
|
@ -108,7 +108,7 @@ class TestListingGeoJsonEndpoint:
|
|||
def mock_export(self):
|
||||
"""Mock the export service."""
|
||||
with patch("api.app.export_service.export_to_geojson") as mock, \
|
||||
patch("api.app._get_disliked_ids", return_value=set()):
|
||||
patch("api.app._get_user_id_safe", return_value=None):
|
||||
mock.return_value = MagicMock(
|
||||
data={"type": "FeatureCollection", "features": [{"type": "Feature"}]}
|
||||
)
|
||||
|
|
@ -175,7 +175,7 @@ class TestStreamingEndpoint:
|
|||
def mock_repository(self):
|
||||
"""Mock the repository methods and bypass cache."""
|
||||
with patch("api.app.get_cached_count", return_value=None), \
|
||||
patch("api.app._get_disliked_ids", return_value=set()), \
|
||||
patch("api.app._get_user_id_safe", return_value=None), \
|
||||
patch("api.app.ListingRepository") as MockRepo:
|
||||
mock_instance = MagicMock()
|
||||
mock_instance.count_listings.return_value = 3
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class TestSetDecision:
|
|||
)
|
||||
assert result.decision == "liked"
|
||||
repo.upsert_decision.assert_called_once_with(
|
||||
user_id=1, listing_id=100, listing_type="RENT", decision="liked"
|
||||
1, 100, "RENT", "liked"
|
||||
)
|
||||
|
||||
def test_set_disliked(self) -> None:
|
||||
|
|
@ -58,7 +58,7 @@ class TestGetDecisions:
|
|||
listing_type="RENT", decision="liked",
|
||||
),
|
||||
]
|
||||
result = decision_service.get_decisions(repo, user_id=1)
|
||||
result = decision_service.get_user_decisions(repo, user_id=1)
|
||||
assert len(result) == 1
|
||||
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ class TestClearDecision:
|
|||
def test_clear_existing(self) -> None:
|
||||
repo = MagicMock()
|
||||
repo.delete_decision.return_value = True
|
||||
result = decision_service.clear_decision(
|
||||
result = decision_service.remove_decision(
|
||||
repo, user_id=1, listing_id=100, listing_type="RENT"
|
||||
)
|
||||
assert result is True
|
||||
|
|
@ -74,7 +74,7 @@ class TestClearDecision:
|
|||
def test_clear_nonexistent(self) -> None:
|
||||
repo = MagicMock()
|
||||
repo.delete_decision.return_value = False
|
||||
result = decision_service.clear_decision(
|
||||
result = decision_service.remove_decision(
|
||||
repo, user_id=1, listing_id=100, listing_type="RENT"
|
||||
)
|
||||
assert result is False
|
||||
|
|
@ -84,7 +84,7 @@ class TestGetDislikedListingIds:
|
|||
def test_returns_disliked_set(self) -> None:
|
||||
repo = MagicMock()
|
||||
repo.get_disliked_listing_ids.return_value = {200, 300}
|
||||
result = decision_service.get_disliked_listing_ids(
|
||||
result = decision_service.get_disliked_ids(
|
||||
repo, user_id=1, listing_type="RENT"
|
||||
)
|
||||
assert result == {200, 300}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue