Skip to content

Commit

Permalink
Fix: Solved last test issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres D. Molins committed Oct 24, 2024
1 parent 700f957 commit bd9a9d6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/aleph/chains/chain_data_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import json
from typing import Any, Dict, List, Mapping, Optional, Self, Set, Type, Union, cast

import aio_pika.abc
Expand Down Expand Up @@ -191,7 +192,7 @@ def _get_tx_messages_smart_contract_protocol(tx: ChainTxDb) -> List[Dict[str, An
item_hash=ItemHash(payload.content),
metadata=None,
)
item_content = content.model_dump_json(exclude_none=True)
item_content = json.dumps(content.model_dump(exclude_none=True))
else:
item_content = payload.content

Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ async def test_get_balance(
response = await ccn_api_client.get(MESSAGES_URI)
assert response.status == 200, await response.text()
data = await response.json()
assert data["balance"] == user_balance.balance
assert data["balance"] == str(user_balance.balance)
assert data["locked_amount"] == 2002.4666666666667
8 changes: 2 additions & 6 deletions tests/api/test_list_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ async def test_get_messages(fixture_messages: Sequence[Dict[str, Any]], ccn_api_
@pytest.mark.asyncio
async def test_get_messages_filter_by_channel(fixture_messages, ccn_api_client):
async def fetch_messages_by_channel(channel: str) -> Dict:
response = await ccn_api_client.get(
MESSAGES_URI, params={"channels": channel}
)
response = await ccn_api_client.get(MESSAGES_URI, params={"channels": channel})
assert response.status == 200, await response.text()
return await response.json()

Expand Down Expand Up @@ -194,9 +192,7 @@ async def test_get_messages_filter_by_tags(
assert len(messages) == 2

# Matching tags for both messages
response = await ccn_api_client.get(
MESSAGES_URI, params={"tags": "original,amend"}
)
response = await ccn_api_client.get(MESSAGES_URI, params={"tags": "original,amend"})
assert response.status == 200, await response.text()
messages = (await response.json())["messages"]
assert len(messages) == 2
Expand Down
4 changes: 1 addition & 3 deletions tests/api/test_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ async def test_get_amended_posts_tags(
session.commit()

# Match one tag
response = await ccn_api_client.get(
"/api/v0/posts.json", params={"tags": "amend"}
)
response = await ccn_api_client.get("/api/v0/posts.json", params={"tags": "amend"})
assert response.status == 200
response_json = await response.json()
assert len(response_json["posts"]) == 1
Expand Down
5 changes: 3 additions & 2 deletions tests/chains/test_chain_data_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime as dt
import json

import pytest
from aleph_message.models import (
Expand Down Expand Up @@ -135,7 +136,7 @@ async def test_smart_contract_protocol_regular_message(
timestamp=1668611900,
addr="KT1VBeLD7hzKpj17aRJ3Kc6QQFeikCEXi7W6",
msgtype="POST",
msgcontent=content.json(),
msgcontent=json.dumps(content.model_dump()),
)

tx = ChainTxDb(
Expand All @@ -146,7 +147,7 @@ async def test_smart_contract_protocol_regular_message(
publisher="KT1BfL57oZfptdtMFZ9LNakEPvuPPA2urdSW",
protocol=ChainSyncProtocol.SMART_CONTRACT,
protocol_version=1,
content=payload.model_dump(),
content=payload.model_dump(mode="json"),
)

chain_data_service = ChainDataService(
Expand Down

0 comments on commit bd9a9d6

Please sign in to comment.