Skip to content

Commit

Permalink
add Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aliel committed Feb 21, 2024
1 parent 5b363c6 commit 5ee9a38
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/aleph/web/controllers/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AggregatesQueryParams(BaseModel):
keys: Optional[List[str]] = None
limit: int = DEFAULT_LIMIT
with_info: bool = False
only_value: bool = False
value_only: bool = False

@validator(
"keys",
Expand Down Expand Up @@ -68,7 +68,7 @@ async def address_aggregate(request: web.Request) -> web.Response:
if not aggregates:
raise web.HTTPNotFound(text="No aggregate found for this address")

if query_params.only_value and query_params.keys and len(query_params.keys) == 1:
if query_params.value_only and query_params.keys and len(query_params.keys) == 1:
output = {}
target_key = query_params.keys[0]
for result in aggregates:
Expand Down
18 changes: 18 additions & 0 deletions tests/api/test_aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,21 @@ async def test_get_aggregates_invalid_params(
errors = await response.json()
assert len(errors) == 1
assert errors[0]["loc"] == ["limit"], errors

@pytest.mark.asyncio
async def test_get_aggregates_return_value_only(
ccn_api_client, fixture_aggregate_messages: Sequence[MessageDb]
):
"""
Should return the value without wrapping (aggregate info)
"""

assert fixture_aggregate_messages # To avoid unused parameter warnings

address, key = ADDRESS_1, "test_target"
aggregates = await get_aggregates_expect_success(
ccn_api_client, address=address, keys=key,
with_info=False, value_only="True"
)
assert address not in aggregates
assert aggregates == EXPECTED_AGGREGATES[address][key]

0 comments on commit 5ee9a38

Please sign in to comment.